aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-03-08 10:38:09 +0100
committerGravatar Christian Hesse <mail@eworm.de>2024-03-12 20:37:57 +0100
commit1feeed145d6b63ef60fc3c0abbe0703b7bd73837 (patch)
treef1839333adac57d8c399349db75229837bacaceb
parent19802c0b6977f9467fada4ace3cab017dd98964b (diff)
global-functions: introduce $LogPrint, deprecate $LogPrintExit2change-123
-rw-r--r--global-functions.rsc21
-rw-r--r--news-and-changes.rsc1
2 files changed, 18 insertions, 4 deletions
diff --git a/global-functions.rsc b/global-functions.rsc
index aca4cd8..1220eca 100644
--- a/global-functions.rsc
+++ b/global-functions.rsc
@@ -12,7 +12,7 @@
:local ScriptName [ :jobname ];
# expected configuration version
-:global ExpectedConfigVersion 122;
+:global ExpectedConfigVersion 123;
# global variables not to be changed by user
:global GlobalFunctionsReady false;
@@ -53,6 +53,7 @@
:global IsFullyConnected;
:global IsMacLocallyAdministered;
:global IsTimeSync;
+:global LogPrint;
:global LogPrintExit2;
:global LogPrintOnce;
:global MAX;
@@ -654,12 +655,11 @@
:return true;
}
-# log and print with same text, optionally exit
-:set LogPrintExit2 do={
+# log and print with same text
+:set LogPrint do={
:local Severity [ :tostr $1 ];
:local Name [ :tostr $2 ];
:local Message [ :tostr $3 ];
- :local Exit [ :tostr $4 ];
:global PrintDebug;
:global PrintDebugOverride;
@@ -692,6 +692,19 @@
:if ($Severity != "debug" || $Debug = true) do={
:put ([ $PrintSeverity $Severity ] . ": " . $Message);
}
+}
+
+# log and print with same text, optionally exit
+# Deprectated! - TODO: remove later
+:set LogPrintExit2 do={
+ :local Severity [ :tostr $1 ];
+ :local Name [ :tostr $2 ];
+ :local Message [ :tostr $3 ];
+ :local Exit [ :tostr $4 ];
+
+ :global LogPrint;
+
+ $LogPrint $1 $2 $3;
:if ($Exit = "true") do={
:error ("Hard error to exit.");
diff --git a/news-and-changes.rsc b/news-and-changes.rsc
index 46b777a..6b0a538 100644
--- a/news-and-changes.rsc
+++ b/news-and-changes.rsc
@@ -47,6 +47,7 @@
120="Implemented a workaround in 'backup-cloud'. Now script should no longer just crash, but send notification with error.";
121="The 'wifiwave2' scripts are finally gone. Development continues with 'wifi' in RouterOS 7.13 and later.";
122="The global configuration was enhanced to support loading snippets. Configuration can be split off to scripts where name starts with 'global-config-overlay.d/'.";
+ 123="Introduced new function '\$LogPrint', and deprecated '\$LogPrintExit2'. Please update custom scripts if you use it.";
};
# Migration steps to be applied on script updates