From e56a9bbec07f94730f4a4bbf1ee2fad734410ccb Mon Sep 17 00:00:00 2001 From: dietmar63 <> Date: Wed, 4 Sep 2013 21:53:36 +0000 Subject: [PATCH] conversion from Log to Log3 git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@3858 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/59_Twilight.pm | 17 ++++++---------- FHEM/98_Heating_Control.pm | 23 +++++++++------------- FHEM/98_RandomTimer.pm | 40 +++++++++++++++----------------------- 3 files changed, 31 insertions(+), 49 deletions(-) diff --git a/FHEM/59_Twilight.pm b/FHEM/59_Twilight.pm index fe1d41f98..66ced4fff 100644 --- a/FHEM/59_Twilight.pm +++ b/FHEM/59_Twilight.pm @@ -73,8 +73,7 @@ sub Twilight_Initialize($) $hash->{DefFn} = "Twilight_Define"; $hash->{UndefFn} = "Twilight_Undef"; $hash->{GetFn} = "Twilight_Get"; - $hash->{AttrList}= "loglevel:0,1,2,3,4,5 ". - $readingFnAttributes; + $hash->{AttrList}= $readingFnAttributes; } # # @@ -236,7 +235,7 @@ sub Twilight_TwilightTimes($$) ($hash->{TW}{$sr}{TIME}, $hash->{TW}{$ss}{TIME})= Twilight_calc($latitude, $longitude, $deg, $declination, $timezone, $midseconds, $timediff); - Log 3, "$hash->{TW}{$sr}{NAME}, $hash->{TW}{$ss}{NAME} are not defined(nan)" if ($hash->{TW}{$sr}{TIME} eq "nan"); + Log3 $hash, 3, "$hash->{TW}{$sr}{NAME}, $hash->{TW}{$ss}{NAME} are not defined(nan)" if ($hash->{TW}{$sr}{TIME} eq "nan"); $hash->{TW}{$sr}{TIME} += 0.01*$idx if ($hash->{TW}{$sr}{TIME} ne "nan"); $hash->{TW}{$ss}{TIME} -= 0.01*$idx if ($hash->{TW}{$ss}{TIME} ne "nan"); @@ -349,12 +348,10 @@ sub Twilight_fireEvent($) my $light = $hash->{TW}{$sx_name}{LIGHT}; my $state = $hash->{TW}{$sx_name}{STATE}; - my $ll = GetLogLevel ($hash->{NAME}, 5); - my $nextEvent = $hash->{TW}{$sx_name}{NEXTE}; my $nextEventTime = "undefined"; $nextEventTime = strftime("%H:%M:%S",localtime($hash->{TW}{$nextEvent}{TIME})) if ($hash->{TW}{$nextEvent}{TIME} ne "nan"); - Log 3, "[".$hash->{NAME}."] " . sprintf ("%-10s state=%-2s light=%-2s nextEvent=%-10s %-14s deg=%+.1f°",$sx_name, $state, $light, $nextEvent, strftime("%d.%m.%Y %H:%M:%S",localtime($hash->{TW}{$nextEvent}{TIME})), $deg); + Log3 $hash, 4, "[".$hash->{NAME}."] " . sprintf ("%-10s state=%-2s light=%-2s nextEvent=%-10s %-14s deg=%+.1f°",$sx_name, $state, $light, $nextEvent, strftime("%d.%m.%Y %H:%M:%S",localtime($hash->{TW}{$nextEvent}{TIME})), $deg); my $eventTime = $hash->{TW}{$sx_name}{TIME}; my $now = time(); @@ -368,7 +365,7 @@ sub Twilight_fireEvent($) readingsBulkUpdate ($hash, "nextEvent", $nextEvent); readingsBulkUpdate ($hash, "nextEventTime", $nextEventTime); - my $doNotTrigger = $hash->{LOCAL}; + my $doNotTrigger = ((defined($hash->{LOCAL})) ? 1 : 0); $doNotTrigger = $doNotTrigger || ($delta > 5); readingsEndUpdate ($hash, !$doNotTrigger); @@ -400,7 +397,6 @@ sub Twilight_getWeatherHorizon($) my $hash=shift; # 0 my $mod = "[".$hash->{NAME} ."] "; - my $ll = GetLogLevel ($hash->{NAME}, 5); my @a_current = (25,25,25,25,20,10,10,10,10,10, 10, 7, 7, 7, 5,10,10, 6, 6, 6, 10, 6 ,6, 6, 6, 6, 6, 5, 5, 3, @@ -411,7 +407,6 @@ sub Twilight_getWeatherHorizon($) my $location=$hash->{WEATHER}; my $url = "http://weather.yahooapis.com/forecastrss?w=".$location."&u=c"; my $xml = GetFileFromURL($url, 3, undef, 1); - #Log $ll, $mod. "xml:\n" .$xml; my $current, my $cond, my $temp, my $aktTemp; if($xml=~/text="(.*)"(\ *)code="(.*)"(\ *)temp="(.*)"(\ *)date/){ @@ -433,7 +428,7 @@ sub Twilight_getWeatherHorizon($) } } - Log 3, "[$hash->{NAME}] " + Log3 $hash, 3, "[$hash->{NAME}] " ."No Weather location found at yahoo weather for location ID: $location\n" ."=======\n" .$xml @@ -460,7 +455,7 @@ sub Twilight_sunpos($) ############################ my $dLongitude = $hash->{LONGITUDE}; my $dLatitude = $hash->{LATITUDE}; - Log 5, "Compute sunpos for latitude $dLatitude , longitude $dLongitude"; + Log3 $hash, 5, "Compute sunpos for latitude $dLatitude , longitude $dLongitude"; my $pi=3.14159265358979323846; my $twopi=(2*$pi); diff --git a/FHEM/98_Heating_Control.pm b/FHEM/98_Heating_Control.pm index 585b6ed6a..6050c7b23 100644 --- a/FHEM/98_Heating_Control.pm +++ b/FHEM/98_Heating_Control.pm @@ -38,7 +38,7 @@ Heating_Control_Initialize($) $hash->{UndefFn} = "Heating_Control_Undef"; $hash->{GetFn} = "Heating_Control_Get"; $hash->{UpdFn} = "Heating_Control_Update"; - $hash->{AttrList}= "disable:0,1 loglevel:0,1,2,3,4,5 ". + $hash->{AttrList}= "disable:0,1". $readingFnAttributes; } @@ -188,7 +188,7 @@ Heating_Control_Define($$) if(!($time =~ m/^[0-2][0-9]:[0-5][0-9]$/g)); for (my $d=0; $d<@days; $d++) { - #Log 3, "Switchingtime: $switchingtimes[$i] : $days[$d] -> $time -> $para "; + #Log3 $hash, 3, "Switchingtime: $switchingtimes[$i] : $days[$d] -> $time -> $para "; $hash->{helper}{SWITCHINGTIME}{$days[$d]}{$time} = $para; } } @@ -255,9 +255,6 @@ Heating_Control_Update($) my $nextSwitch = 0; my $nowSwitch = 0; - my $loglevel = GetLogLevel ($hash->{NAME}, 5); - # $loglevel = 3; - my $startIdx; for (my $d=-1; $d>=-7; $d--) { my $wd = ($d+$wday) % 7; @@ -277,7 +274,7 @@ Heating_Control_Update($) my $next = $now + $secondsToSwitch; if ($secondsToSwitch<=10 && $secondsToSwitch>=-20) { - Log $loglevel, $mod." Jetzt:".strftime('%d.%m.%Y %H:%M:%S',localtime($now))." -> Next: ".strftime('%d.%m.%Y %H:%M:%S',localtime($next))." -> Temp: $hash->{helper}{SWITCHINGTIME}{$wd}{$st} ".$secondsToSwitch; + Log3 $hash, 4, $mod." Jetzt:".strftime('%d.%m.%Y %H:%M:%S',localtime($now))." -> Next: ".strftime('%d.%m.%Y %H:%M:%S',localtime($next))." -> Temp: $hash->{helper}{SWITCHINGTIME}{$wd}{$st} ".$secondsToSwitch; } if ($secondsToSwitch<=0) { $newDesTemperature = $hash->{helper}{SWITCHINGTIME}{$wd}{$st}; @@ -297,8 +294,8 @@ Heating_Control_Update($) my $command; #$nextSwitch += get_SummerTimeOffset($now, $nextSwitch); - Log $loglevel, $mod .strftime('%d.%m.%Y %H:%M:%S',localtime($nowSwitch))." ; AktDesiredTemp: $AktDesiredTemp ; newDesTemperature: $newDesTemperature"; - Log $loglevel, $mod .strftime('%d.%m.%Y %H:%M:%S',localtime($nextSwitch)); + Log3 $hash, 4, $mod .strftime('%d.%m.%Y %H:%M:%S',localtime($nowSwitch))." ; AktDesiredTemp: $AktDesiredTemp ; newDesTemperature: $newDesTemperature"; + Log3 $hash, 4, $mod .strftime('%d.%m.%Y %H:%M:%S',localtime($nextSwitch)); if ($nowSwitch gt "" && $AktDesiredTemp ne $newDesTemperature ) { if (defined $hash->{helper}{CONDITION}) { @@ -314,9 +311,9 @@ Heating_Control_Update($) $command =~ s/@/$hash->{DEVICE}/g; $command =~ s/%/$newDesTemperature/g; $command = SemicolonEscape($command); - Log $loglevel, $mod."command: $command"; + Log3 $hash, 4, $mod."command: $command"; my $ret = AnalyzeCommandChain(undef, $command); - Log GetLogLevel($name,3), $ret if($ret); + Log3 ($hash, 3, $ret) if($ret); } my $active = 1; @@ -348,9 +345,9 @@ sub Heating_Control_SetAllTemps() { # {Heating_Control_SetAllTemps()} } } Heating_Control_Update($hash); - Log 3, "Heating_Control_Update() for $hash->{NAME} done!"; + Log3 undef, 3, "Heating_Control_Update() for $hash->{NAME} done!"; } - Log 3, "Heating_Control_SetAllTemps() done!"; + Log3 undef, 3, "Heating_Control_SetAllTemps() done!"; } sub SortNumber { @@ -448,7 +445,6 @@ sub SortNumber { Attributes