log-forward: use comparison for ids

This was introduced with RouterOS 7.22beta1.
This commit is contained in:
Christian Hesse 2026-01-13 21:02:02 +01:00
parent c9f0c5a9f2
commit 44663f0c38

View file

@ -24,7 +24,6 @@
:global LogForwardRateLimit;
:global EitherOr;
:global HexToNum;
:global IfThenElse;
:global LogForwardFilterLogForwarding;
:global LogPrint;
@ -38,6 +37,9 @@
:error false;
}
# LogForwardLast is not initialized, by intention: we want
# to catch *0 on first invocation!
:if ([ :typeof $LogForwardRateLimit ] = "nothing") do={
:set LogForwardRateLimit 0;
}
@ -51,7 +53,6 @@
:local Count 0;
:local Duplicates false;
:local Last [ $IfThenElse ([ :len $LogForwardLast ] > 0) [ $HexToNum $LogForwardLast ] -1 ];
:local Messages "";
:local Warning false;
:local MessageVal;
@ -63,14 +64,13 @@
:set LogForwardIncludeMessage [ $EitherOr $LogForwardIncludeMessage [] ];
:local LogForwardFilterLogForwardingCached [ $EitherOr [ $LogForwardFilterLogForwarding ] ("\$^") ];
:foreach Message in=[ /log/find where (!(message="") and \
!(message~$LogForwardFilterLogForwardingCached) and \
!(topics~$LogForwardFilter) and !(message~$LogForwardFilterMessage)) or \
topics~$LogForwardInclude or message~$LogForwardIncludeMessage ] do={
:foreach Message in=[ /log/find where .id>$LogForwardLast and \
((!(message="") and !(message~$LogForwardFilterLogForwardingCached) and \
!(topics~$LogForwardFilter) and !(message~$LogForwardFilterMessage)) or \
topics~$LogForwardInclude or message~$LogForwardIncludeMessage) ] do={
:set MessageVal [ /log/get $Message ];
:local Bullet "information";
:if ($Last < [ $HexToNum ($MessageVal->".id") ]) do={
:local DupCount ($MessageDups->($MessageVal->"message"));
:if ($MessageVal->"topics" ~ "(warning)") do={
:set Warning true;
@ -88,7 +88,6 @@
}
:set ($MessageDups->($MessageVal->"message")) ($DupCount + 1);
:set Count ($Count + 1);
}
}
:if ($Count > 0) do={