diff --git a/FHEM/92_FileLog.pm b/FHEM/92_FileLog.pm index bc6727d60..17df1e564 100644 --- a/FHEM/92_FileLog.pm +++ b/FHEM/92_FileLog.pm @@ -54,6 +54,7 @@ FileLog_Initialize($) logtype mseclog:1,0 nrarchive + outputFormat reformatFn ); use warnings 'qw'; @@ -196,6 +197,7 @@ FileLog_Log($$) my $fh; my $switched; my $written = 0; + my $fmt = AttrVal($ln, "outputFormat", undef); for (my $i = 0; $i < $max; $i++) { my $s = $events->[$i]; @@ -211,7 +213,12 @@ FileLog_Log($$) } $fh = $log->{FH}; $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++; } } @@ -254,6 +261,13 @@ FileLog_Attr(@) if($a[0] eq "set" && $a[2] eq "disable") { $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")); return if(!$do); @@ -1355,8 +1369,15 @@ FileLog_regexpFn($$)