From 1ca7e74415e6259ab0b7e1cd95b954268f48ed44 Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Thu, 11 Oct 2018 19:00:17 +0000 Subject: [PATCH] 93_Log2Syslog: send BSD-format changed, commandref revised git-svn-id: https://svn.fhem.de/fhem/trunk@17510 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/93_Log2Syslog.pm | 41 +- fhem/contrib/DS_Starter/93_Log2Syslog.pm | 3265 ---------------------- 3 files changed, 24 insertions(+), 3283 deletions(-) delete mode 100644 fhem/contrib/DS_Starter/93_Log2Syslog.pm diff --git a/fhem/CHANGED b/fhem/CHANGED index 45eec016c..e87e8c143 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - change: 93_Log2Syslog: send BSD-format changed, commandref revised - bugfix: 93_DbRep: fix don't get the real min timestamp in special cases - bugfix: 51_MOBILEALERTS: Fix temperature for MA10320PRO - change: 93_DbLog, 93_DbRep: minor fix time until DB is closed diff --git a/fhem/FHEM/93_Log2Syslog.pm b/fhem/FHEM/93_Log2Syslog.pm index 7b152cf28..db486337c 100644 --- a/fhem/FHEM/93_Log2Syslog.pm +++ b/fhem/FHEM/93_Log2Syslog.pm @@ -35,6 +35,7 @@ use warnings; # Versions History intern: our %Log2Syslog_vNotesIntern = ( + "5.2.1" => "08.10.2018 setpayload of BSD-format changed, commandref revised ", "5.2.0" => "02.10.2018 added direct help for attributes", "5.1.0" => "01.10.2018 new get versionNotes command", "5.0.1" => "27.09.2018 Log2Syslog_closesock if write error:.* , delete readings code changed", @@ -84,6 +85,7 @@ our %Log2Syslog_vNotesIntern = ( # Versions History extern: our %Log2Syslog_vNotesExtern = ( + "5.2.1" => "08.10.2018 Send format of BSD changed. The TAG-field was changed to \"IDENT[PID]: \" ", "5.2.0" => "02.10.2018 direct help for attributes added", "5.1.0" => "29.09.2018 new get <name> versionNotes command ", "5.0.1" => "27.09.2018 automatic reconnect to syslog-server in case of write error ", @@ -1741,7 +1743,7 @@ sub Log2Syslog_setpayload ($$$$$$) { my $myhost = $hash->{MYHOST}?$hash->{MYHOST}:"0.0.0.0"; my $myfqdn = $hash->{MYFQDN}?$hash->{MYFQDN}:"0.0.0.0"; my $lf = AttrVal($name, "logFormat", "IETF"); - my $tag = AttrVal($name, "contDelimiter", ""); # Trennzeichen vor Content (z.B. für Synology nötig) + my $cdl = AttrVal($name, "contDelimiter", ""); # Trennzeichen vor Content (z.B. für Synology nötig) my $data; return undef,undef if(!$otp); @@ -1752,13 +1754,13 @@ sub Log2Syslog_setpayload ($$$$$$) { if ($lf eq "BSD") { # BSD Protokollformat https://tools.ietf.org/html/rfc3164 - $time = (split(/\./,$time))[0] if($time =~ m/\./); # msec ist nicht erlaubt - $month = $Log2Syslog_BSDMonth{$month}; # Monatsmapping, z.B. 01 -> Jan - $day =~ s/0/ / if($day =~ m/^0.*$/); # in Tagen < 10 muss 0 durch Space ersetzt werden - $ident = substr($ident,0, $RFC3164len{TAG}); # Länge TAG Feld begrenzen + $time = (split(/\./,$time))[0] if($time =~ m/\./); # msec ist nicht erlaubt + $month = $Log2Syslog_BSDMonth{$month}; # Monatsmapping, z.B. 01 -> Jan + $day =~ s/0/ / if($day =~ m/^0.*$/); # in Tagen < 10 muss 0 durch Space ersetzt werden + my $tag = substr($ident,0, $RFC3164len{TAG}); # Länge TAG Feld begrenzen no warnings 'uninitialized'; - $ident = $ident.$tag."[$pid]:"; - $data = "<$prival>$month $day $time $myhost $ident$otp"; + $tag = $tag."[$pid]: ".$cdl; # TAG-Feld um PID und Content-Delimiter ergänzen + $data = "<$prival>$month $day $time $myhost $tag$otp"; use warnings; $data = substr($data,0, ($RFC3164len{DL}-1)); # Länge Total begrenzen } @@ -1780,7 +1782,7 @@ sub Log2Syslog_setpayload ($$$$$$) { no warnings 'uninitialized'; if ($IETFver == 1) { - $data = "<$prival>$IETFver $tim $myfqdn $ident $pid $mid $sdfield $tag$otp"; + $data = "<$prival>$IETFver $tim $myfqdn $ident $pid $mid $sdfield $cdl$otp"; } use warnings; } @@ -1953,9 +1955,11 @@ return;
@@ -2120,7 +2124,7 @@ Aug 18 21:08:27 fhemtest.myds.me 1 2017-08-18T21:08:27.095 fhemtest.myds.me Test The structure of the payload differs dependent of the used logFormat.

logFormat IETF:

- "<PRIVAL>IETFVERS TIME MYHOST IDENT PID MID [SD-FIELD] :MESSAGE"

+ "<PRIVAL>IETFVERS TIME MYHOST IDENT PID MID [SD-FIELD] MESSAGE"