From 90e6c462d2eca984e419d66ca232bebcf3f6fa60 Mon Sep 17 00:00:00 2001
From: rudolfkoenig <>
Date: Wed, 25 Dec 2019 19:17:36 +0000
Subject: [PATCH] fhem.pl: implement ignoreRegexp for the global FHEM log
(Forum #104520)
git-svn-id: https://svn.fhem.de/fhem/trunk@20827 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/FHEM/91_notify.pm | 4 ++--
fhem/docs/commandref_frame.html | 7 +++++++
fhem/docs/commandref_frame_DE.html | 7 +++++++
fhem/fhem.pl | 9 +++++++++
4 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/fhem/FHEM/91_notify.pm b/fhem/FHEM/91_notify.pm
index 0f7c2e33b..5ec89aa2b 100644
--- a/fhem/FHEM/91_notify.pm
+++ b/fhem/FHEM/91_notify.pm
@@ -778,8 +778,8 @@ END
ignoreRegexp regexp
Es ist nicht immer einfach ein Regexp zu bauen, was etwas _nicht_
matcht. Dieses Attribu hilft in diesen Fällen: das Event wird
- ignoriert, falls den angegebenen Regexp. Syntax ist gleich wie in der
- Definition.
+ ignoriert, falls den angegebenen Regexp matcht. Syntax ist gleich wie
+ in der Definition.
diff --git a/fhem/docs/commandref_frame.html b/fhem/docs/commandref_frame.html
index e846c7cb6..128d99753 100644
--- a/fhem/docs/commandref_frame.html
+++ b/fhem/docs/commandref_frame.html
@@ -1567,6 +1567,13 @@ The following local attributes are used by a wider range of devices:
compression by default. Set httpcompress to 0 to disable this feature.
+
+ ignoreRegexp
+ Do not log messages matching the value into the FHEM log. Note: the
+ usual ^ and $ will be appended to the regexp, like in notify or
+ FileLog.
+
+
keyFileName
FHEM modules store passwords and unique IDs in the file
diff --git a/fhem/docs/commandref_frame_DE.html b/fhem/docs/commandref_frame_DE.html
index 75e59ae9e..68464074d 100644
--- a/fhem/docs/commandref_frame_DE.html
+++ b/fhem/docs/commandref_frame_DE.html
@@ -1671,6 +1671,13 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
httpcompress auf 0 setzt, wird die Komprimierung deaktiviert.
+
+ ignoreRegexp
+ Texte, wo dieses Regexp matcht, werden nicht geloggt. ^ und $ wird zum
+ Regexp hinzugefügt, wie bei notify und FileLog.
+
+
+
keyFileName
FHEM Module speichern Passwörter und IDs in der Datei
diff --git a/fhem/fhem.pl b/fhem/fhem.pl
index ccd13c163..96e6bdc5d 100755
--- a/fhem/fhem.pl
+++ b/fhem/fhem.pl
@@ -303,6 +303,7 @@ my @cmdList; # Remaining commands in a chain. Used by sleep
my %sleepers; # list of sleepers
my %delayedShutdowns; # definitions needing delayed shutdown
my %fuuidHash; # for duplicate checking
+my $ignoreRegexp; # for Log filtering
$init_done = 0;
$lastDefChange = 0;
@@ -338,6 +339,7 @@ my @globalAttrList = qw(
genericDisplayType:switch,outlet,light,blind,speaker,thermostat
holiday2we
httpcompress:0,1
+ ignoreRegexp
keyFileName
language:EN,DE
lastinclude
@@ -969,6 +971,7 @@ Log3($$$)
return if($loglevel > $attr{global}{verbose});
}
+ return if($ignoreRegexp && $text =~ m/^$ignoreRegexp$/);
my ($seconds, $microseconds) = gettimeofday();
my @t = localtime($seconds);
@@ -2752,6 +2755,7 @@ GlobalAttr($$$$)
return "The global attribute $name cannot be deleted" if($noDel{$name});
$featurelevel = 5.9 if($name eq "featurelevel");
$haveInet6 = 0 if($name eq "useInet6"); # IPv6
+ $ignoreRegexp = 0 if($name eq "ignoreRegexp");
return undef;
}
@@ -2846,6 +2850,11 @@ GlobalAttr($$$$)
$haveInet6 = 0;
}
}
+ elsif($name eq "ignoreRegexp") {
+ eval { "Hallo" =~ m/^$val$/ };
+ return $@ if($@);
+ $ignoreRegexp = $val;
+ }
return undef;
}