mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
92_FileLog.pm: add outputFormat attribute (Forum #104951)
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@20435 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
5a13ada5aa
commit
f1aa78cb01
@ -54,6 +54,7 @@ FileLog_Initialize($)
|
|||||||
logtype
|
logtype
|
||||||
mseclog:1,0
|
mseclog:1,0
|
||||||
nrarchive
|
nrarchive
|
||||||
|
outputFormat
|
||||||
reformatFn
|
reformatFn
|
||||||
);
|
);
|
||||||
use warnings 'qw';
|
use warnings 'qw';
|
||||||
@ -196,6 +197,7 @@ FileLog_Log($$)
|
|||||||
my $fh;
|
my $fh;
|
||||||
my $switched;
|
my $switched;
|
||||||
my $written = 0;
|
my $written = 0;
|
||||||
|
my $fmt = AttrVal($ln, "outputFormat", undef);
|
||||||
|
|
||||||
for (my $i = 0; $i < $max; $i++) {
|
for (my $i = 0; $i < $max; $i++) {
|
||||||
my $s = $events->[$i];
|
my $s = $events->[$i];
|
||||||
@ -211,7 +213,12 @@ FileLog_Log($$)
|
|||||||
}
|
}
|
||||||
$fh = $log->{FH};
|
$fh = $log->{FH};
|
||||||
$s =~ s/\n/ /g;
|
$s =~ s/\n/ /g;
|
||||||
print $fh "$t $n $s\n";
|
if($fmt) {
|
||||||
|
my ($TIMESTAMP,$NAME,$EVENT) = ($t, $n, $s);
|
||||||
|
print $fh eval $fmt;
|
||||||
|
} else {
|
||||||
|
print $fh "$t $n $s\n";
|
||||||
|
}
|
||||||
$written++;
|
$written++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,6 +261,13 @@ FileLog_Attr(@)
|
|||||||
if($a[0] eq "set" && $a[2] eq "disable") {
|
if($a[0] eq "set" && $a[2] eq "disable") {
|
||||||
$do = (!defined($a[3]) || $a[3]) ? 1 : 2;
|
$do = (!defined($a[3]) || $a[3]) ? 1 : 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($a[0] eq "set" && $a[2] eq "outputFormat") {
|
||||||
|
my ($TIMESTAMP,$EVENT,$NAME) = ("2000-01-01_01:01:01","test","test");
|
||||||
|
eval $a[3];
|
||||||
|
return $@ if($@);
|
||||||
|
}
|
||||||
|
|
||||||
$do = 2 if($a[0] eq "del" && (!$a[2] || $a[2] eq "disable"));
|
$do = 2 if($a[0] eq "del" && (!$a[2] || $a[2] eq "disable"));
|
||||||
return if(!$do);
|
return if(!$do);
|
||||||
|
|
||||||
@ -1355,8 +1369,15 @@ FileLog_regexpFn($$)
|
|||||||
|
|
||||||
<li><a href="#mseclog">mseclog</a></li><br>
|
<li><a href="#mseclog">mseclog</a></li><br>
|
||||||
|
|
||||||
|
<a name="outputFormat"></a>
|
||||||
|
<li>outputFormat <perlCode><br>
|
||||||
|
If set, the result of the evaluated perlCode will be written to the file.
|
||||||
|
Default is "$TIMESTAMP $NAME $EVENT\n".<br>
|
||||||
|
Note: only this format ist compatible with the SVG Editor
|
||||||
|
</li><br>
|
||||||
|
|
||||||
<a name="reformatFn"></a>
|
<a name="reformatFn"></a>
|
||||||
<li>reformatFn<br>
|
<li>reformatFn <perlFunctionName><br>
|
||||||
used to convert "foreign" logfiles for the SVG Module, contains the
|
used to convert "foreign" logfiles for the SVG Module, contains the
|
||||||
name(!) of a function, which will be called with a "raw" line from the
|
name(!) of a function, which will be called with a "raw" line from the
|
||||||
original file, and has to return a line in "FileLog" format.<br>
|
original file, and has to return a line in "FileLog" format.<br>
|
||||||
@ -1682,8 +1703,15 @@ FileLog_regexpFn($$)
|
|||||||
|
|
||||||
<li><a href="#mseclog">mseclog</a></li><br>
|
<li><a href="#mseclog">mseclog</a></li><br>
|
||||||
|
|
||||||
|
<a name="outputFormat"></a>
|
||||||
|
<li>outputFormat <perlCode><br>
|
||||||
|
Falls gesetzt, ist die Ausgabezeile das Ergebnis der Auswertung.
|
||||||
|
Voreinstellung ist "$TIMESTAMP $NAME $EVENT\n".<br>
|
||||||
|
Achtung: nur dieses Format ist kompatibel mit dem SVG-Editor.
|
||||||
|
</li><br>
|
||||||
|
|
||||||
<a name="reformatFn"></a>
|
<a name="reformatFn"></a>
|
||||||
<li>reformatFn<br>
|
<li>reformatFn <perlFunktionsName><br>
|
||||||
wird verwendet, um "fremde" Dateien für die SVG-Anzeige ins
|
wird verwendet, um "fremde" Dateien für die SVG-Anzeige ins
|
||||||
FileLog-Format zu konvertieren. Es enthält nur den Namen einer
|
FileLog-Format zu konvertieren. Es enthält nur den Namen einer
|
||||||
Funktion, der mit der ursprünglichen Zeile aufgerufen wird. Z.Bsp.
|
Funktion, der mit der ursprünglichen Zeile aufgerufen wird. Z.Bsp.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user