changed: logging optimized

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@3630 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
betateilchen 2013-08-08 20:30:36 +00:00
parent e7a116efed
commit 3957f9e337
3 changed files with 43 additions and 34 deletions

View File

@ -6,7 +6,7 @@
# An FHEM Perl module to retrieve data from "Deutscher Wetterdienst" # An FHEM Perl module to retrieve data from "Deutscher Wetterdienst"
# #
# Copyright: betateilchen ® # Copyright: betateilchen ®
# e-mail : fhem.development@betateilchen.de # e-mail: fhem.development@betateilchen.de
# #
# This file is part of fhem. # This file is part of fhem.
# #
@ -207,7 +207,7 @@ sub GDS_Define($$$) {
my @a = split("[ \t][ \t]*", $def); my @a = split("[ \t][ \t]*", $def);
return "syntax: define <name> GDS <username> <password>" if(int(@a) != 4 ); return "syntax: define <name> GDS <username> <password>" if(int(@a) != 4 );
my $name = $hash->{NAME};
$hash->{helper}{USER} = $a[2]; $hash->{helper}{USER} = $a[2];
$hash->{helper}{PASS} = $a[3]; $hash->{helper}{PASS} = $a[3];
$hash->{helper}{URL} = "ftp-outgoing2.dwd.de"; $hash->{helper}{URL} = "ftp-outgoing2.dwd.de";
@ -217,7 +217,7 @@ sub GDS_Define($$$) {
$sList = getListStationsDropdown(); $sList = getListStationsDropdown();
retrieveFile($hash,"alerts"); retrieveFile($hash,"alerts");
($aList, undef) = buildCAPList(); ($aList, undef) = buildCAPList();
Log 3, "GDS $name created";
$hash->{STATE} = "active"; $hash->{STATE} = "active";
return undef; return undef;
@ -509,6 +509,7 @@ sub buildCAPList(){
sub decodeCAPData($$){ sub decodeCAPData($$){
my ($hash, $datensatz) = @_; my ($hash, $datensatz) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $loglevel = GetLogLevel($name,3);
my $info = int($datensatz/100); my $info = int($datensatz/100);
my $area = $datensatz-$info*100; my $area = $datensatz-$info*100;
@ -519,6 +520,8 @@ sub decodeCAPData($$){
my $_gdsLong = AttrVal($name,"gdsLong", 0); my $_gdsLong = AttrVal($name,"gdsLong", 0);
my $_gdsPolygon = AttrVal($name,"gdsPolygon", 0); my $_gdsPolygon = AttrVal($name,"gdsPolygon", 0);
Log $loglevel, "GDS $name: Decoding CAP record #".$datensatz;
# topLevel informations # topLevel informations
@dummy = split(/\./, $alertsXml->{identifier}); @dummy = split(/\./, $alertsXml->{identifier});
@ -628,6 +631,7 @@ sub retrieveTextWarn($@){
sub retrieveConditions($$@){ sub retrieveConditions($$@){
my ($hash, $prefix, @a) = @_; my ($hash, $prefix, @a) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $loglevel = GetLogLevel($name,3);
my $user = $hash->{helper}{USER}; my $user = $hash->{helper}{USER};
my $pass = $hash->{helper}{PASS}; my $pass = $hash->{helper}{PASS};
(my $myStation = utf8ToLatin1($a[2])) =~ s/_/ /g; # replace underscore in stationName by space (my $myStation = utf8ToLatin1($a[2])) =~ s/_/ /g; # replace underscore in stationName by space
@ -637,6 +641,8 @@ sub retrieveConditions($$@){
$debug = AttrVal($name, "gdsDebug", 0); $debug = AttrVal($name, "gdsDebug", 0);
Log $loglevel, "GDS $name: Retrieving conditions data";
($dataFile, $found) = retrieveFile($hash,"conditions"); ($dataFile, $found) = retrieveFile($hash,"conditions");
open WXDATA, "/tmp/conditions"; open WXDATA, "/tmp/conditions";
while (chomp($line = <WXDATA>)) { while (chomp($line = <WXDATA>)) {
@ -697,6 +703,7 @@ sub retrieveFile($$;$){
# #
my ($hash, $request, $parameter) = @_; my ($hash, $request, $parameter) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $loglevel = GetLogLevel($name,3);
my $user = $hash->{helper}{USER}; my $user = $hash->{helper}{USER};
my $pass = $hash->{helper}{PASS}; my $pass = $hash->{helper}{PASS};
my $proxyName = AttrVal($name, "gdsProxyName", ""); my $proxyName = AttrVal($name, "gdsProxyName", "");
@ -731,6 +738,8 @@ sub retrieveFile($$;$){
} }
} }
Log $loglevel, "GDS $name: retrieving $dir".$dwd." from DWD server";
$found = 0; $found = 0;
eval { eval {
$ftp = Net::FTP->new( "ftp-outgoing2.dwd.de", $ftp = Net::FTP->new( "ftp-outgoing2.dwd.de",

View File

@ -6,7 +6,7 @@
# via network connection. # via network connection.
# #
# Copyright: betateilchen ® # Copyright: betateilchen ®
# e-mail : fhem.development@betateilchen.de # e-mail: fhem.development@betateilchen.de
# #
# This file is part of fhem. # This file is part of fhem.
# #

View File

@ -219,7 +219,7 @@ sub
OWO_GetStatus($;$){ OWO_GetStatus($;$){
my ($hash, $local) = @_; my ($hash, $local) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $loglevel = AttrVal($name, "loglevel", 3); my $loglevel = GetLogLevel($name,3);
$local = 0 unless(defined($local)); $local = 0 unless(defined($local));
$attr{$name}{"owoInterval"} = 600 if(AttrVal($name,"owoInterval",0) < 600); $attr{$name}{"owoInterval"} = 600 if(AttrVal($name,"owoInterval",0) < 600);
@ -335,7 +335,7 @@ sub
UpdateReadings($$$){ UpdateReadings($$$){
my ($hash, $url, $prefix) = @_; my ($hash, $url, $prefix) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $loglevel = AttrVal($name, "loglevel", 3); my $loglevel = GetLogLevel($name,3);
my ($jsonWeather, $response); my ($jsonWeather, $response);
$url .= "&APPID=".AttrVal($name, "owoApiKey", ""); $url .= "&APPID=".AttrVal($name, "owoApiKey", "");
# $response = GetFileFromURL("$url"); # $response = GetFileFromURL("$url");