From f46db918453dcb8878b9a0de6e122fb0ea2224d9 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 22 Feb 2021 15:14:10 +0100 Subject: global: give script or function name in log messages --- collect-wireless-mac.template | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'collect-wireless-mac.template') diff --git a/collect-wireless-mac.template b/collect-wireless-mac.template index 2198136..fe84287 100644 --- a/collect-wireless-mac.template +++ b/collect-wireless-mac.template @@ -9,13 +9,14 @@ # !! This is just a template! Replace '%PATH%' with 'caps-man' # !! or 'interface wireless'! +:local 0 "collect-wireless-mac%TEMPL%"; :global GlobalFunctionsReady; :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :global Identity; :global GetMacVendor; -:global LogPrintExit; +:global LogPrintExit2; :global ScriptLock; :global SendNotification; :global SymbolForNotification; @@ -24,7 +25,7 @@ $ScriptLock "collect-wireless-mac%TEMPL%"; :if ([ :len [ / %PATH% access-list find where comment="--- collected above ---" disabled ] ] = 0) do={ / %PATH% access-list add comment="--- collected above ---" disabled=yes; - $LogPrintExit warning "Added disabled access-list entry with comment '--- collected above ---'." false; + $LogPrintExit2 warning $0 ("Added disabled access-list entry with comment '--- collected above ---'.") false; } :local PlaceBefore ([ / %PATH% access-list find where comment="--- collected above ---" disabled ]->0); @@ -55,7 +56,7 @@ $ScriptLock "collect-wireless-mac%TEMPL%"; :local Vendor [ $GetMacVendor $Mac ]; :local Message ("unknown MAC address " . $Mac . " (" . $Vendor . ", " . $HostName . ") " . \ "first seen on " . $DateTime . " connected to SSID " . $Ssid . ", interface " . $Interface); - $LogPrintExit info $Message false; + $LogPrintExit2 info $0 $Message false; / %PATH% access-list add place-before=$PlaceBefore comment=$Message mac-address=$Mac disabled=yes; $SendNotification ([ $SymbolForNotification "mobile-phone" ] . $Mac . " connected to " . $Ssid) \ ("A device with unknown MAC address connected to " . $Ssid . " on " . $Identity . ".\n\n" . \ @@ -69,7 +70,7 @@ $ScriptLock "collect-wireless-mac%TEMPL%"; "DNS name: " . $DnsName . "\n" . \ "Date: " . $DateTime); } else={ - $LogPrintExit debug ("MAC address " . $Mac . " already known: " . \ + $LogPrintExit2 debug $0 ("MAC address " . $Mac . " already known: " . \ [ / %PATH% access-list get $AccessList comment ]) false; } } -- cgit v1.2.3-54-g00ecf