Hallo,
bei mir friert die Ausgabe von Plots unter Windows 7 32 Bit, Strawberry Perl mit dem Modul 92_FileLog.pm vom 5.12.2015 (# $Id: 92_FileLog.pm 10085 2015-12-04 15:41:21Z rudolfkoenig $) ein. Mit einer früheren Version (# $Id: 92_FileLog.pm 9838 2015-11-09 17:32:44Z rudolfkoenig $) tritt dieses nicht auf.
Anscheinend ist hier etwas zu viel verloren gegangen. Leider habe ich mich noch nict so gut in Perl eingearbeitet, um direkt den Fehler anzugeben.
Funktioniert:
###################################
#($1-40587)*86400+$2
sub
FileLog_seekTo($$$$$)
{
my ($fname, $fh, $hash, $ts, $reformatFn) = @_;
# If its cached
if($hash->{pos} && $hash->{pos}{"$fname:$ts"}) {
$fh->seek($hash->{pos}{"$fname:$ts"}, 0);
return;
}
$fh->seek(0, 2); # Go to the end
my $upper = $fh->tell;
my ($lower, $next, $last) = (0, $upper/2, 0);
while() { # Binary search
$fh->seek($next, 0);
my $data = <$fh>;
if(!$data) {
$last = $next;
last;
}
if($reformatFn) { no strict; $data = &$reformatFn($data); use strict; }
if($data !~ m/^\d\d\d\d-\d\d-\d\d_\d\d:\d\d:\d\d /o) {
$next = $fh->tell;
$data = <$fh>;
if(!$data) {
$last = seekBackOneLine($fh, $next);
last;
}
if($reformatFn) { no strict; $data = &$reformatFn($data); use strict; }
# If the second line is longer then the first,
# binary search will never get it:
if($next eq $last && $data ge $ts) {
$last = seekBackOneLine($fh, $next);
last;
}
}
if($next eq $last) {
$fh->seek($next, 0);
last;
}
$last = $next;
if(!$data || $data lt $ts) {
($lower, $next) = ($next, int(($next+$upper)/2));
} else {
($upper, $next) = ($next, int(($lower+$next)/2));
}
}
$hash->{pos}{"$fname:$ts"} = $last;
}
Funktioniert nicht:
###################################
#($1-40587)*86400+$2
sub
FileLog_seekTo($$$$$)
{
my ($fname, $fh, $hash, $ts, $reformatFn) = @_;
# If its cached
if($hash->{pos} && $hash->{pos}{"$fname:$ts"}) {
$fh->seek($hash->{pos}{"$fname:$ts"}, 0);
return;
}
$fh->seek(0, 2); # Go to the end
my $upper = $fh->tell;
my ($lower, $next, $last) = (0, $upper/2, -1);
while() { # Binary search
if($next == $last) {
$fh->seek($next, 0);
last;
}
$fh->seek($next, 0);
my $data = <$fh>;
if(!$data) {
$last = $next;
last;
}
if($reformatFn) { no strict; $data = &$reformatFn($data); use strict; }
if($data !~ m/^\d\d\d\d-\d\d-\d\d_\d\d:\d\d:\d\d /o) {
$next = seekBackOneLine($fh, $fh->tell);
next;
}
$last = $next;
if(!$data || $data lt $ts) {
($lower, $next) = ($next, int(($next+$upper)/2));
} else {
($upper, $next) = ($next, int(($lower+$next)/2));
}
}
$hash->{pos}{"$fname:$ts"} = $last;
}
Hallo!
Das aktuelle 92_FileLog.pm ist
# $Id: 92_FileLog.pm 10111 2015-12-06 11:06:00Z rudolfkoenig $
und dort wurde etwas iZm Windows gefixt. Vielleicht mal updaten und testen; evtl. hilft es...
Gruß, Christian
Wurde vermutlich gestern gefixt, siehe http://forum.fhem.de/index.php?topic=45221 (http://forum.fhem.de/index.php?topic=45221)
Danke,
ich hatte zwar nach Filelog gesucht aber keinen Eintrag gefunden.
Ansonsten, wunderbares Programm und vielen Dank an alle Programmierer!