From 3ebf68a08c94e23d742a37815caa3c55b6985806 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 26 Feb 2020 12:09:19 +0100 Subject: global-functions: $LogAndError: add severity --- check-certificates | 2 +- check-routeros-update | 4 ++-- email-backup | 2 +- global-functions | 7 ++++--- ipv6-update | 2 +- lease-script | 2 +- packages-update | 2 +- ppp-on-up | 2 +- sms-action | 2 +- sms-forward | 2 +- update-tunnelbroker | 2 +- upload-backup | 2 +- 12 files changed, 16 insertions(+), 15 deletions(-) diff --git a/check-certificates b/check-certificates index ccc7b15..d7c4c8e 100644 --- a/check-certificates +++ b/check-certificates @@ -22,7 +22,7 @@ } :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={ diff --git a/check-routeros-update b/check-routeros-update index 7f14701..ff5bc38 100644 --- a/check-routeros-update +++ b/check-routeros-update @@ -25,7 +25,7 @@ :if ([ / system package print count-only where name="wireless" disabled=no ] > 0) do={ :if ([ / interface wireless cap get enabled ] = true && \ [ / 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 ]; :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={ diff --git a/email-backup b/email-backup index 9761206..45e7703 100644 --- a/email-backup +++ b/email-backup @@ -18,7 +18,7 @@ :if ($BackupSendBinary != true && \ $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 diff --git a/global-functions b/global-functions index 335df62..0e3b5f1 100644 --- a/global-functions +++ b/global-functions @@ -492,8 +492,9 @@ # log and error with same text :set LogAndError do={ - :local Message [ :tostr $1 ]; + :local Severity [ :tostr $1 ]; + :local Message [ :tostr $2 ]; - :log warn $Message; - :error $Message; + [ :parse (":log " . $Severity . " \$Message") ]; + :error ($Severity . ": " . $Message); } diff --git a/ipv6-update b/ipv6-update index 52c02db..eee3536 100644 --- a/ipv6-update +++ b/ipv6-update @@ -10,7 +10,7 @@ :global LogAndError; :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 ]; diff --git a/lease-script b/lease-script index 588c9ff..9109ea9 100644 --- a/lease-script +++ b/lease-script @@ -10,7 +10,7 @@ [ :typeof $leaseActMAC ] = "nothing" || \ [ :typeof $leaseServerName ] = "nothing" || \ [ :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; diff --git a/packages-update b/packages-update index 04a25c8..b4233c8 100644 --- a/packages-update +++ b/packages-update @@ -26,7 +26,7 @@ $ScriptLock "packages-update"; :foreach Package in=[ / system package find where !bundle ] do={ :local PkgName [ / system package get $Package name ]; if ([ $DownloadPackage $PkgName ($Update->"latest-version") ] = false) do={ - $LogAndError ("Download for package " . $PkgName . " failed."); + $LogAndError error ("Download for package " . $PkgName . " failed."); } } diff --git a/ppp-on-up b/ppp-on-up index 6c72a94..415663c 100644 --- a/ppp-on-up +++ b/ppp-on-up @@ -9,7 +9,7 @@ :local Interface $interface; :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 ]; diff --git a/sms-action b/sms-action index 5eabdd5..ceb9071 100644 --- a/sms-action +++ b/sms-action @@ -11,7 +11,7 @@ :local Action $action; :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); diff --git a/sms-forward b/sms-forward index 8907d19..f03ab27 100644 --- a/sms-forward +++ b/sms-forward @@ -12,7 +12,7 @@ # check mail server :if ($MailServerIsUp = false) do={ - $LogAndError "Mail server is not up."; + $LogAndError warning "Mail server is not up."; } :local Settings [ / tool sms get ]; diff --git a/update-tunnelbroker b/update-tunnelbroker index 1dd11f1..138fac7 100644 --- a/update-tunnelbroker +++ b/update-tunnelbroker @@ -8,7 +8,7 @@ :global LogAndError; :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 diff --git a/upload-backup b/upload-backup index a761007..817a088 100644 --- a/upload-backup +++ b/upload-backup @@ -20,7 +20,7 @@ :if ($BackupSendBinary != true && \ $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 -- cgit v1.2.3-54-g00ecf