diff --git a/fhem/CHANGED b/fhem/CHANGED index a649bf035..bda8b1a2a 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. + - feature: 93_Log2Syslog: support time-secfrac of RFC 3339, minor fix - feature: 93_Log2Syslog: new attribute 'timeSpec', send and parse messages according to UTC or Local tiime, some code changes (e.g. for Octet count format msg) diff --git a/fhem/FHEM/93_Log2Syslog.pm b/fhem/FHEM/93_Log2Syslog.pm index 76959cc17..ad4ab2f90 100644 --- a/fhem/FHEM/93_Log2Syslog.pm +++ b/fhem/FHEM/93_Log2Syslog.pm @@ -44,6 +44,7 @@ eval "use FHEM::Meta;1" or my $mod # Versions History intern: my %Log2Syslog_vNotesIntern = ( + "5.10.1" => "06.04.2020 support time-secfrac of RFC 3339, minor fix ", "5.10.0" => "04.04.2020 new attribute 'timeSpec', send and parse messages according to UTC or Local time, some minor fixes (e.g. for Octet Count) ", "5.9.0" => "01.04.2020 Parser UniFi Controller Syslog (BSD Format) and Netconsole messages, more code review (e.g. remove prototypes) ", "5.8.3" => "31.03.2020 fix warning uninitialized value \$pp in pattern match (m//) at line 465, Forum: topic,75426.msg1036553.html#msg1036553, some code review ", @@ -339,15 +340,14 @@ sub Log2Syslog_Define { $hash->{MYFQDN} = $myfqdn // $hash->{MYHOST}; - if(int(@a)-3 < 0){ - # Einrichtung Servermode (Collector) + if(int(@a)-3 < 0){ # Einrichtung Servermode (Collector) $hash->{MODEL} = "Collector"; $hash->{PROFILE} = "Automatic"; readingsSingleUpdate ($hash, 'Parse_Err_No', 0, 1); # Fehlerzähler für Parse-Errors auf 0 Log2Syslog_Log3slog ($hash, 3, "Log2Syslog $name - entering Syslog servermode ..."); Log2Syslog_initServer("$name,global"); - } else { - # Sendermode + + } else { # Sendermode $hash->{MODEL} = "Sender"; Log2Syslog_setidrex($hash,$a[3]) if($a[3]); Log2Syslog_setidrex($hash,$a[4]) if($a[4]); @@ -408,6 +408,7 @@ sub Log2Syslog_initServer { InternalTimer(gettimeofday()+1, "Log2Syslog_initServer", "$name,$global", 0); return; } + # Inititialisierung FHEM ist fertig -> Attribute geladen my $port = AttrVal($name, "TLS", 0)?AttrVal($name, "port", 6514):AttrVal($name, "port", 1514); my $protocol = lc(AttrVal($name, "protocol", "udp")); @@ -445,7 +446,7 @@ sub Log2Syslog_initServer { $hash->{PROTOCOL} = $protocol; $hash->{SEQNO} = 1; # PROCID wird kontinuierlich pro empfangenen Datensatz hochgezählt $hash->{HELPER}{OLDSEQNO} = $hash->{SEQNO}; # Init Sequenznummer f. Ratenbestimmung - $hash->{INTERFACE} = $lh?$lh:"global"; + $hash->{INTERFACE} = $lh // "global"; Log2Syslog_Log3slog ($hash, 3, "Log2Syslog $name - port $hash->{PORT}/$protocol opened for Syslog Collector on interface \"$hash->{INTERFACE}\""); readingsSingleUpdate ($hash, "state", "initialized", 1); @@ -513,13 +514,13 @@ sub Log2Syslog_Read { my $i = 0; $ocount = $+{ocount}; $tail = $+{tail}; - if(length($tail) >= $ocount) { - $msg = substr($tail,0,$ocount); - } else { - $msg = $tail; - } + $msg = substr($tail,0,$ocount); push @load, $msg; - $tail = substr($tail,$ocount); + if(length($tail) >= $ocount) { + $tail = substr($tail,$ocount); + } else { + $tail = ""; + } Log2Syslog_Log3slog ($hash, 5, "Log2Syslog $name -> OCTETCOUNT$i: $ocount"); Log2Syslog_Log3slog ($hash, 5, "Log2Syslog $name -> MSG$i : $msg"); @@ -746,8 +747,8 @@ sub Log2Syslog_parsePayload { # Hash zur Umwandlung Felder in deren Variablen my ($prival,$ts,$host,$date,$time,$id,$pid,$mid,$sdfield,$cont); - my $fac = ""; - my $sev = ""; + my ($fac,$sev,$msec) = ("","",""); + my %fh = (PRIVAL => \$prival, FAC => \$fac, SEV => \$sev, @@ -874,11 +875,12 @@ sub Log2Syslog_parsePayload { if($prival && $ietf) { # Standard IETF-Syslog incl. VERSION if($ietf == 1) { - $data =~ /^<(?\d{1,3})>(?\d{0,2})\s?(?\d{4}-\d{2}-\d{2})T(?