global-functions: $LogAndError: add severity

This commit is contained in:
Christian Hesse 2020-02-26 12:09:19 +01:00
parent 6ef764c7d7
commit 3ebf68a08c
12 changed files with 16 additions and 15 deletions

View file

@ -22,7 +22,7 @@
} }
:if ($TimeIsSync = false) do={ :if ($TimeIsSync = false) do={
$LogAndError "Time is not yet synchronized."; $LogAndError warning "Time is not yet synchronized.";
} }
:foreach Cert in=[ / certificate find where !revoked !ca expires-after<3w ] do={ :foreach Cert in=[ / certificate find where !revoked !ca expires-after<3w ] do={

View file

@ -25,7 +25,7 @@
:if ([ / system package print count-only where name="wireless" disabled=no ] > 0) do={ :if ([ / system package print count-only where name="wireless" disabled=no ] > 0) do={
:if ([ / interface wireless cap get enabled ] = true && \ :if ([ / interface wireless cap get enabled ] = true && \
[ / caps-man manager get enabled ] = false) do={ [ / caps-man manager get enabled ] = false) do={
$LogAndError "System is managed by CAPsMAN, not checking."; $LogAndError error "System is managed by CAPsMAN, not checking.";
} }
} }
@ -37,7 +37,7 @@
:local Update [ / system package update get ]; :local Update [ / system package update get ];
:if ([ :len ($Update->"latest-version") ] = 0) do={ :if ([ :len ($Update->"latest-version") ] = 0) do={
$LogAndError "An empty string is not a valid version."; $LogAndError warning "An empty string is not a valid version.";
} }
:if ($Update->"installed-version" != $Update->"latest-version") do={ :if ($Update->"installed-version" != $Update->"latest-version") do={

View file

@ -18,7 +18,7 @@
:if ($BackupSendBinary != true && \ :if ($BackupSendBinary != true && \
$BackupSendExport != true) do={ $BackupSendExport != true) do={
$LogAndError ("Configured to send neither backup nor config export."); $LogAndError error ("Configured to send neither backup nor config export.");
} }
# filename based on identity # filename based on identity

View file

@ -492,8 +492,9 @@
# log and error with same text # log and error with same text
:set LogAndError do={ :set LogAndError do={
:local Message [ :tostr $1 ]; :local Severity [ :tostr $1 ];
:local Message [ :tostr $2 ];
:log warn $Message; [ :parse (":log " . $Severity . " \$Message") ];
:error $Message; :error ($Severity . ": " . $Message);
} }

View file

@ -10,7 +10,7 @@
:global LogAndError; :global LogAndError;
:if ([ :typeof $PdPrefix ] = "nothing") do={ :if ([ :typeof $PdPrefix ] = "nothing") do={
$LogAndError "This script is supposed to run from ipv6 dhcp-client."; $LogAndError error "This script is supposed to run from ipv6 dhcp-client.";
} }
:local Pool [ / ipv6 pool get [ find where prefix=$PdPrefix ] name ]; :local Pool [ / ipv6 pool get [ find where prefix=$PdPrefix ] name ];

View file

@ -10,7 +10,7 @@
[ :typeof $leaseActMAC ] = "nothing" || \ [ :typeof $leaseActMAC ] = "nothing" || \
[ :typeof $leaseServerName ] = "nothing" || \ [ :typeof $leaseServerName ] = "nothing" || \
[ :typeof $leaseBound ] = "nothing") do={ [ :typeof $leaseBound ] = "nothing") do={
$LogAndError "This script is supposed to run from ip dhcp-client."; $LogAndError error "This script is supposed to run from ip dhcp-client.";
} }
:local Scripts; :local Scripts;

View file

@ -26,7 +26,7 @@ $ScriptLock "packages-update";
:foreach Package in=[ / system package find where !bundle ] do={ :foreach Package in=[ / system package find where !bundle ] do={
:local PkgName [ / system package get $Package name ]; :local PkgName [ / system package get $Package name ];
if ([ $DownloadPackage $PkgName ($Update->"latest-version") ] = false) do={ if ([ $DownloadPackage $PkgName ($Update->"latest-version") ] = false) do={
$LogAndError ("Download for package " . $PkgName . " failed."); $LogAndError error ("Download for package " . $PkgName . " failed.");
} }
} }

View file

@ -9,7 +9,7 @@
:local Interface $interface; :local Interface $interface;
:if ([ :typeof $Interface ] = "nothing") do={ :if ([ :typeof $Interface ] = "nothing") do={
$LogAndError "This script is supposed to run from ppp on-up script hook."; $LogAndError error "This script is supposed to run from ppp on-up script hook.";
} }
:local IntName [ / interface get $Interface name ]; :local IntName [ / interface get $Interface name ];

View file

@ -11,7 +11,7 @@
:local Action $action; :local Action $action;
:if ([ :typeof $Action ] = "nothing") do={ :if ([ :typeof $Action ] = "nothing") do={
$LogAndError "This script is supposed to run from SMS hook with action=..."; $LogAndError error "This script is supposed to run from SMS hook with action=...";
} }
:local Code ($SmsAction->$Action); :local Code ($SmsAction->$Action);

View file

@ -12,7 +12,7 @@
# check mail server # check mail server
:if ($MailServerIsUp = false) do={ :if ($MailServerIsUp = false) do={
$LogAndError "Mail server is not up."; $LogAndError warning "Mail server is not up.";
} }
:local Settings [ / tool sms get ]; :local Settings [ / tool sms get ];

View file

@ -8,7 +8,7 @@
:global LogAndError; :global LogAndError;
:if ([ / ip cloud get ddns-enabled ] != true) do={ :if ([ / ip cloud get ddns-enabled ] != true) do={
$LogAndError "IP cloud DDNS is not enabled."; $LogAndError error "IP cloud DDNS is not enabled.";
} }
# Get the current ip address from cloud # Get the current ip address from cloud

View file

@ -20,7 +20,7 @@
:if ($BackupSendBinary != true && \ :if ($BackupSendBinary != true && \
$BackupSendExport != true) do={ $BackupSendExport != true) do={
$LogAndError ("Configured to send neither backup nor config export."); $LogAndError error ("Configured to send neither backup nor config export.");
} }
# filename based on identity # filename based on identity