From 9e6c27d5f0b052955e8f56c94bdb01c9cfa3eb31 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Mon, 8 Aug 2016 08:30:59 +0000 Subject: [PATCH] 92_FileLog.pm: add eventOnThreshold attribtue (Forum #56051) git-svn-id: https://svn.fhem.de/fhem/trunk@11920 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/92_FileLog.pm | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/fhem/FHEM/92_FileLog.pm b/fhem/FHEM/92_FileLog.pm index 88e403cb9..267b72719 100755 --- a/fhem/FHEM/92_FileLog.pm +++ b/fhem/FHEM/92_FileLog.pm @@ -47,6 +47,7 @@ FileLog_Initialize($) createGluedFile:0,1 disable:0,1 disabledForIntervals + eventOnThreshold logtype nrarchive reformatFn @@ -182,6 +183,7 @@ FileLog_Log($$) my $ct = $dev->{CHANGETIME}; my $fh; my $switched; + my $written = 0; for (my $i = 0; $i < $max; $i++) { my $s = $events->[$i]; @@ -196,13 +198,24 @@ FileLog_Log($$) } $fh = $log->{FH}; print $fh "$t $n $s\n"; + $written++; } } + return "" if(!$written); + if($fh) { $fh->flush; # Skip sync, it costs too much HD strain, esp. on SSD # $fh->sync if !($^O eq 'MSWin32'); #not implemented in Windows } + my $owr = ReadingsVal($ln, "linesInTheFile", 0); + my $eot = AttrVal($ln, "eventOnThreshold", 0); + if($eot && ($owr+$written) % $eot == 0) { + readingsSingleUpdate($log, "linesInTheFile", $owr+$written, 1); + } else { + setReadingsVal($log, "linesInTheFile", $owr+$written, $tn); + } + return ""; } @@ -1257,6 +1270,15 @@ FileLog_regexpFn($$)
define fhtlog1 FileLog log/fht1-%Y-%U.log fht1:.*(temp|actuator).*
+ define fhtlog1 FileLog log/fht1-%Y-%U.log
+ fht1:.*(temp|actuator).*