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).*