mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-22 08:11:44 +00:00
92_FileLog.pm: more general case for createGluedFile (Forum #95712)
git-svn-id: https://svn.fhem.de/fhem/trunk@18224 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
f3dc5af6be
commit
1f936174b1
@ -618,7 +618,7 @@ FileLog_Get($@)
|
|||||||
}
|
}
|
||||||
|
|
||||||
my $reformatFn = AttrVal($name, "reformatFn", "");
|
my $reformatFn = AttrVal($name, "reformatFn", "");
|
||||||
my $tempread;
|
my $tempfileName;
|
||||||
|
|
||||||
if($inf eq "-") {
|
if($inf eq "-") {
|
||||||
# In case now is after midnight, before the first event is logged.
|
# In case now is after midnight, before the first event is logged.
|
||||||
@ -628,38 +628,43 @@ FileLog_Get($@)
|
|||||||
} else {
|
} else {
|
||||||
my $linf;
|
my $linf;
|
||||||
if($inf eq "CURRENT") {
|
if($inf eq "CURRENT") {
|
||||||
# Try to guess
|
if($from =~ m/^(....)-(..)-(..)/) { # compute the log filename
|
||||||
if($from =~ m/^(....)-(..)-(..)/) {
|
my ($fy,$fm,$fd) = ($1,$2,$3);
|
||||||
$linf = $hash->{logfile};
|
$linf = ResolveDateWildcards($hash->{logfile},
|
||||||
my ($Y,$m,$d) = ($1,$2,$3);
|
localtime(time_str2num("$fy-$fm-$fd 00:00:00")));
|
||||||
sub expandFileWildcards($$$$) {
|
|
||||||
my ($f,$Y,$m,$d)=@_;
|
|
||||||
return ResolveDateWildcards($f,
|
|
||||||
localtime(time_str2num("$Y-$m-$d 00:00:00")));
|
|
||||||
};
|
|
||||||
$linf=expandFileWildcards($linf,$Y,$m,$d);
|
|
||||||
if(AttrVal($name, "createGluedFile", 0)) {
|
if(AttrVal($name, "createGluedFile", 0)) {
|
||||||
if($to =~ m/^(....)-(..)-(..)/) {
|
if($to =~ m/^(....)-(..)-(..)/) {
|
||||||
my $linf_to = $hash->{logfile};
|
my ($ty,$tm,$td) = ($1,$2,$3);
|
||||||
my ($Y,$m,$d) = ($1,$2,$3);
|
my $linf_to = ResolveDateWildcards($hash->{logfile},
|
||||||
$linf_to=expandFileWildcards($linf_to,$Y,$m,$d);
|
localtime(time_str2num("$ty-$tm-$td 00:00:00")));
|
||||||
if($linf ne $linf_to){ # use to log files
|
if($linf ne $linf_to){ # append each file into a temporary one
|
||||||
$tempread=$linf_to.".transit.temp.log";
|
$tempfileName = $linf.".transit.temp.log";
|
||||||
if(open(my $temp,'>',$tempread)){
|
unlink($tempfileName);
|
||||||
|
my $lf = $linf;
|
||||||
|
|
||||||
|
if(open(my $out,'>',$tempfileName)){
|
||||||
|
my $sec = time_str2num("$fy-$fm-$fd 00:00:00");
|
||||||
|
my $secTo = time_str2num("$ty-$tm-$td 00:00:00");
|
||||||
|
my $lastFile = "";
|
||||||
|
while($sec <= $secTo) { # Loop over each day
|
||||||
|
$linf=ResolveDateWildcards($hash->{logfile},localtime($sec));
|
||||||
|
$sec += 86400;
|
||||||
|
if($linf ne $lastFile) {
|
||||||
|
$lastFile = $linf;
|
||||||
if(open(my $i,'<',$linf)){
|
if(open(my $i,'<',$linf)){
|
||||||
print $temp join("",<$i>);
|
print $out join("",<$i>);
|
||||||
close($i);
|
close($i);
|
||||||
}
|
}
|
||||||
if(open(my $i,'<',$linf_to)){
|
|
||||||
print $temp join("",<$i>);
|
|
||||||
close($i);
|
|
||||||
}
|
}
|
||||||
$linf=$tempread;
|
}
|
||||||
close($temp);
|
$linf = $tempfileName;
|
||||||
|
close($out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$linf = $hash->{currentlogfile} if($linf =~ m/%/ || ! -f $linf);
|
$linf = $hash->{currentlogfile} if($linf =~ m/%/ || ! -f $linf);
|
||||||
} else {
|
} else {
|
||||||
$linf = $hash->{currentlogfile};
|
$linf = $hash->{currentlogfile};
|
||||||
@ -772,7 +777,6 @@ RESCAN:
|
|||||||
next if($rescan && $h->{ret});
|
next if($rescan && $h->{ret});
|
||||||
my @missingvals;
|
my @missingvals;
|
||||||
next if($h->{re} && $l !~ m/$h->{re}/); # 20% CPU
|
next if($h->{re} && $l !~ m/$h->{re}/); # 20% CPU
|
||||||
|
|
||||||
my $col = $h->{col};
|
my $col = $h->{col};
|
||||||
my $t = $h->{type};
|
my $t = $h->{type};
|
||||||
|
|
||||||
@ -884,7 +888,7 @@ RESCAN:
|
|||||||
}
|
}
|
||||||
|
|
||||||
$ifh->close() if($ifh);
|
$ifh->close() if($ifh);
|
||||||
unlink($tempread) if($tempread);
|
unlink($tempfileName) if($tempfileName);
|
||||||
|
|
||||||
my $ret = "";
|
my $ret = "";
|
||||||
for(my $i = 0; $i < int(@a); $i++) {
|
for(my $i = 0; $i < int(@a); $i++) {
|
||||||
@ -1314,8 +1318,8 @@ FileLog_regexpFn($$)
|
|||||||
<a name="createGluedFile"></a>
|
<a name="createGluedFile"></a>
|
||||||
<li>createGluedFile<br>
|
<li>createGluedFile<br>
|
||||||
If set (to 1), and the SVG-Plot requests a time-range wich is stored
|
If set (to 1), and the SVG-Plot requests a time-range wich is stored
|
||||||
in two files, a temporary file with the content of both files will be
|
in multiple files, a temporary file with the content of all files will
|
||||||
created, in order to satisfy the request.
|
be created, in order to satisfy the request. Note: this may be slow.
|
||||||
</li><br>
|
</li><br>
|
||||||
|
|
||||||
<li><a href="#disable">disable</a></li>
|
<li><a href="#disable">disable</a></li>
|
||||||
@ -1607,8 +1611,8 @@ FileLog_regexpFn($$)
|
|||||||
<a name="createGluedFile"></a>
|
<a name="createGluedFile"></a>
|
||||||
<li>createGluedFile<br>
|
<li>createGluedFile<br>
|
||||||
Falls gesetzt (1), und im SVG-Plot ein Zeitbereich abgefragt wird, was
|
Falls gesetzt (1), und im SVG-Plot ein Zeitbereich abgefragt wird, was
|
||||||
in zwei Logdateien gespeichert ist, dann wird für die Anfrage eine
|
in mehreren Logdateien gespeichert ist, dann wird für die Anfrage
|
||||||
temporäre Datei mit dem Inhalt der beiden Dateien erzeugt.
|
eine temporäre Datei mit dem Inhalt aller Dateien erzeugt.
|
||||||
</li><br>
|
</li><br>
|
||||||
|
|
||||||
<li><a href="#disable">disable</a></li>
|
<li><a href="#disable">disable</a></li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user