aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-10-27 08:42:32 +0200
committerGravatar Christian Hesse <mail@eworm.de>2023-10-27 08:42:32 +0200
commit72b485125500cb30572f6bb31cff3c1f551fb766 (patch)
tree3074c589b61f68f0a8faeece5af014be8478c682
parentdce779250c4546570579a901ae7dcba87429fabe (diff)
global-functions: introduce $LogPrintOnce
This does work just like $LogPrintExit2, except it acts just *once* for each message, until device is rebooted.
-rw-r--r--global-functions.rsc23
1 files changed, 23 insertions, 0 deletions
diff --git a/global-functions.rsc b/global-functions.rsc
index 96b8845..bacda7c 100644
--- a/global-functions.rsc
+++ b/global-functions.rsc
@@ -45,6 +45,7 @@
:global IsMacLocallyAdministered;
:global IsTimeSync;
:global LogPrintExit2;
+:global LogPrintOnce;
:global MkDir;
:global NotificationFunctions;
:global ParseDate;
@@ -613,6 +614,28 @@
}
}
+# log and print, once until reboot
+:set LogPrintOnce do={
+ :local Severity [ :tostr $1 ];
+ :local Name [ :tostr $2 ];
+ :local Message [ :tostr $3 ];
+
+ :global LogPrintExit2;
+
+ :global LogPrintOnceMessages;
+
+ :if ([ :typeof $LogPrintOnceMessages ] = "nothing") do={
+ :set LogPrintOnceMessages ({});
+ }
+
+ :if ($LogPrintOnceMessages->$Message = 1) do={
+ :return true;
+ }
+
+ :set ($LogPrintOnceMessages->$Message) 1;
+ $LogPrintExit2 $Severity $Name $Message false;
+}
+
# create directory
:set MkDir do={
:local Path [ :tostr $1 ];