From 4927e338056caee72b9c202a4cc69b2b7322363f Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Sat, 9 Feb 2019 12:27:42 +0000 Subject: [PATCH] 93_DbLog: CommandRef revised git-svn-id: https://svn.fhem.de/fhem/trunk@18544 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/93_DbLog.pm | 75 ++++++++++++++++++++++++++----------------- 2 files changed, 47 insertions(+), 29 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 21419d5e3..a46b77c22 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. + - changed: 93_DbLog: CommandRef revised - feature: 98_HTTPMOD: starting with featurelevel >5.9 enableCookies, enableControlSet, handleRedirects and enforceGoodReadingNames will default to 1 diff --git a/fhem/FHEM/93_DbLog.pm b/fhem/FHEM/93_DbLog.pm index 8fbcc8d87..e1e1da3d1 100644 --- a/fhem/FHEM/93_DbLog.pm +++ b/fhem/FHEM/93_DbLog.pm @@ -10,12 +10,13 @@ # # reduceLog() created by Claudiu Schuster (rapster) # -# redesigned 2016-2018 by DS_Starter with credits by -# JoeAllb, DeeSpe +# redesigned 2016-2019 by DS_Starter with credits by: JoeAllb, DeeSpe # ############################################################################################################################################ # Versions History done by DS_Starter: # +# 3.13.2 09.02.2019 Commandref revised +# 3.13.1 27.11.2018 DbLog_ExecSQL log output changed # 3.13.0 12.11.2018 adding attributes traceFlag, traceLevel # 3.12.7 10.11.2018 addLog considers DbLogInclude (Forum:#92854) # 3.12.6 22.10.2018 fix timer not deleted if reopen after reopen xxx (Forum: https://forum.fhem.de/index.php/topic,91869.msg848433.html#msg848433) @@ -217,7 +218,7 @@ use Time::Local; use Encode qw(encode_utf8); no if $] >= 5.017011, warnings => 'experimental::smartmatch'; -my $DbLogVersion = "3.13.0"; +my $DbLogVersion = "3.13.1"; my %columns = ("DEVICE" => 64, "TYPE" => 64, @@ -2488,12 +2489,15 @@ sub DbLog_ConnectNewDBH($) { # # param1: DbLog-hash # param2: SQL-Statement +# ########################################################################## -sub DbLog_ExecSQL($$) -{ +sub DbLog_ExecSQL($$) { my ($hash,$sql)= @_; - Log3 $hash->{NAME}, 4, "Executing $sql"; - my $dbh = DbLog_ConnectNewDBH($hash); + my $name = $hash->{NAME}; + my $dbh = DbLog_ConnectNewDBH($hash); + + Log3($name, 4, "DbLog $name - Backdoor executing: $sql"); + return if(!$dbh); my $sth = DbLog_ExecSQL1($hash,$dbh,$sql); if(!$sth) { @@ -2501,31 +2505,37 @@ sub DbLog_ExecSQL($$) $dbh->disconnect(); $dbh = DbLog_ConnectNewDBH($hash); return if(!$dbh); + + Log3($name, 2, "DbLog $name - Backdoor retry: $sql"); $sth = DbLog_ExecSQL1($hash,$dbh,$sql); if(!$sth) { - Log3 $hash->{NAME}, 2, "DBLog retry failed."; + Log3($name, 2, "DbLog $name - Backdoor retry failed"); $dbh->disconnect(); return 0; } - Log3 $hash->{NAME}, 2, "DBLog retry ok."; + Log3($name, 2, "DbLog $name - Backdoor retry ok"); } eval {$dbh->commit() if(!$dbh->{AutoCommit});}; $dbh->disconnect(); - return $sth; + +return $sth; } -sub DbLog_ExecSQL1($$$) -{ +sub DbLog_ExecSQL1($$$) { my ($hash,$dbh,$sql)= @_; + my $name = $hash->{NAME}; + $dbh->{RaiseError} = 1; $dbh->{PrintError} = 0; + my $sth; eval { $sth = $dbh->do($sql); }; if($@) { - Log3 $hash->{NAME}, 2, "DBLog error: $@"; + Log3($name, 2, "DbLog $name - ERROR: $@"); return 0; } - return $sth; + +return $sth; } ################################################################ @@ -5997,8 +6007,10 @@ sub DbLog_dbReadings($@) { A new Attribute DbLogInclude will be propagated to all Devices if DBLog is used. DbLogInclude works just like DbLogExclude but to include matching readings. - See also DbLogSelectionMode-Attribute of DbLog-Device which takes influence on - on how DbLogExclude and DbLogInclude are handled.
+ If a MinInterval is set, the logentry is dropped if the defined interval is not reached and the value vs. + lastvalue is equal. + See also DbLogSelectionMode-Attribute of DbLog device which takes influence on how DbLogExclude and DbLogInclude + are handled.

Example
attr MyDevice1 DbLogInclude .*
@@ -6013,9 +6025,11 @@ sub DbLog_dbReadings($@) { attr <device> DbLogExclude regex:MinInterval,[regex:MinInterval] ...
- A new Attribute DbLogExclude will be propagated to all Devices if DBLog is used. - DbLogExclude will work as regexp to exclude defined readings to log. Each individual regexp-group are separated by comma. - If a MinInterval is set, the logentry is dropped if the defined interval is not reached and value vs. lastvalue is eqal. + A new Attribute DbLogExclude will be propagated to all devices if DBLog is used. + DbLogExclude will work as regexp to exclude defined readings to log. Each individual regexp-group are separated by + comma. + If a MinInterval is set, the logentry is dropped if the defined interval is not reached and the value vs. + lastvalue is equal.

Example
@@ -7136,9 +7150,9 @@ sub DbLog_dbReadings($@) { attr <device> DbLogSelectionMode [Exclude|Include|Exclude/Include]
- Dieses, fuer DbLog-Devices spezifische Attribut beeinflußt, wie die Device-spezifischen Attributes + Dieses fuer DbLog-Devices spezifische Attribut beeinflußt, wie die Device-spezifischen Attribute DbLogExclude und DbLogInclude (s.u.) ausgewertet werden.
- Fehlt dieses Attribut, wird dafuer "Exclude" als Default angenommen.
+ Fehlt dieses Attribut, wird "Exclude" als Default angenommen.