From 72b485125500cb30572f6bb31cff3c1f551fb766 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 27 Oct 2023 08:42:32 +0200 Subject: global-functions: introduce $LogPrintOnce This does work just like $LogPrintExit2, except it acts just *once* for each message, until device is rebooted. --- global-functions.rsc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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 ]; -- cgit v1.2.3-70-g09d2