From 109c72eb8bb7024de3c27b647b65bb5264af78a1 Mon Sep 17 00:00:00 2001 From: DS_Starter Date: Sun, 28 Jan 2018 14:32:37 +0000 Subject: [PATCH] 93_DbLog:V3.8.0, log events containing pipe "|" possible git-svn-id: https://svn.fhem.de/fhem/trunk@16021 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/93_DbLog.pm | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 5af6bb548..e3d242443 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_DbLog:V3.8.0, log events containing pipe "|" possible - bugfix: 98_TRAFFIC: v1.3.5, fixed return readings in DbLog_SplitFn - feature: attr: -a and -r Options added (Forum #83414) - feature: 20_FRM_IN: added Firmata 2.5 feature PIN_MODE_PULLUP diff --git a/fhem/FHEM/93_DbLog.pm b/fhem/FHEM/93_DbLog.pm index 524854136..5763c9fa4 100644 --- a/fhem/FHEM/93_DbLog.pm +++ b/fhem/FHEM/93_DbLog.pm @@ -16,6 +16,7 @@ ############################################################################################################################################ # Versions History done by DS_Starter & DeeSPe: # +# 3.8.0 26.01.2018 escape "|" in events to log events containing it # 3.7.1 25.01.2018 fix typo in commandref # 3.7.0 21.01.2018 parsed event with Log 5 added, configCheck enhanced by configuration read check # 3.6.5 19.01.2018 fix lot of logentries if disabled and db not available @@ -180,7 +181,7 @@ use Blocking; use Time::HiRes qw(gettimeofday tv_interval); use Encode qw(encode_utf8); -my $DbLogVersion = "3.7.1"; +my $DbLogVersion = "3.8.0"; my %columns = ("DEVICE" => 64, "TYPE" => 64, @@ -1222,6 +1223,7 @@ sub DbLog_Log($$) { if($dev_name =~ m/^$re$/ || "$dev_name:$event" =~ m/^$re$/ || $DbLogSelectionMode eq 'Include') { my $timestamp = $ts_0; $timestamp = $dev_hash->{CHANGETIME}[$i] if(defined($dev_hash->{CHANGETIME}[$i])); + $event =~ s/\|/_ESC_/g; # escape Pipe "|" my @r = DbLog_ParseEvent($dev_name, $dev_type, $event); $reading = $r[0]; @@ -1362,7 +1364,7 @@ sub DbLog_Log($$) { return if($hash->{HELPER}{REOPEN_RUNS}); my $error = DbLog_Push($hash, $vb4show, @row_array); Log3 $name, 5, "DbLog $name -> DbLog_Push Returncode: $error" if($vb4show); - + my $state = $error?$error:(IsDisabled($name))?"disabled":"connected"; my $evt = ($state eq $hash->{HELPER}{OLDSTATE})?0:1; readingsSingleUpdate($hash, "state", $state, $evt); @@ -1445,6 +1447,7 @@ sub DbLog_Push(@) { foreach my $row (@row_array) { my @a = split("\\|",$row); + s/_ESC_/\|/g for @a; # escaped Pipe return to "|" push(@timestamp, "$a[0]"); push(@device, "$a[1]"); push(@type, "$a[2]"); @@ -1850,7 +1853,8 @@ sub DbLog_PushAsync(@) { my $ceti = $#row_array+1; foreach my $row (@row_array) { - my @a = split("\\|",$row); + my @a = split("\\|",$row); + s/_ESC_/\|/g for @a; # escaped Pipe return to "|" push(@timestamp, "$a[0]"); push(@device, "$a[1]"); push(@type, "$a[2]"); @@ -1984,6 +1988,7 @@ sub DbLog_PushAsync(@) { Log3 $hash->{NAME}, 4, "DbLog $name -> $ceti of $ceti events inserted into table history".($usepkh?" using PK on columns $pkh":""); } else { Log3 $hash->{NAME}, 4, "DbLog $name -> ".($ceti-$nins_hist)." of $ceti events inserted into table history".($usepkh?" using PK on columns $pkh":""); + s/\|/_ESC_/g for @n2hist; # escape Pipe "|" $rowlist = join('ยง', @n2hist); $rowlist = encode_base64($rowlist,""); }