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;
@ -466,18 +466,18 @@ sub setHelp(){
# #
sub buildCAPList(){ sub buildCAPList(){
my $xml = new XML::Simple; my $xml = new XML::Simple;
$alertsXml = undef; $alertsXml = undef;
$alertsXml = $xml->XMLin('/tmp/alerts', KeyAttr => {}, ForceArray => [ 'info', 'eventCode', 'area', 'geocode' ]); $alertsXml = $xml->XMLin('/tmp/alerts', KeyAttr => {}, ForceArray => [ 'info', 'eventCode', 'area', 'geocode' ]);
my $info = 0; my $info = 0;
my $area = 0; my $area = 0;
my $record = 0; my $record = 0;
my $n = 0; my $n = 0;
my ($capCity, $capCell, $capExit, @a, $list); my ($capCity, $capCell, $capExit, @a, $list);
%capCityHash = (); %capCityHash = ();
%capCellHash = (); %capCellHash = ();
$aList = undef; $aList = undef;
while(1) { while(1) {
$area = 0; $area = 0;
@ -508,9 +508,10 @@ sub buildCAPList(){
sub decodeCAPData($$){ sub decodeCAPData($$){
my ($hash, $datensatz) = @_; my ($hash, $datensatz) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $info = int($datensatz/100); my $loglevel = GetLogLevel($name,3);
my $area = $datensatz-$info*100; my $info = int($datensatz/100);
my $area = $datensatz-$info*100;
my (%readings, @dummy, $i, $k, $n, $v, $t); my (%readings, @dummy, $i, $k, $n, $v, $t);
@ -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
@ -636,6 +640,8 @@ sub retrieveConditions($$@){
my (%alignment, $dataFile, $decodeDummy, $debug, @files, $found, $ftp, $item, $line, %pos, %wx, $wx, %cread, $k, $v); my (%alignment, $dataFile, $decodeDummy, $debug, @files, $found, $ftp, $item, $line, %pos, %wx, $wx, %cread, $k, $v);
$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";
@ -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

@ -1,27 +1,27 @@
# $Id$ # $Id$
############################################################################## ##############################################################################
# #
# 71_LISTENLIVE.pm # 71_LISTENLIVE.pm
# An FHEM Perl module for controlling ListenLive-enabled Mediaplayers # An FHEM Perl module for controlling ListenLive-enabled Mediaplayers
# 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.
# #
# Fhem is free software: you can redistribute it and/or modify # Fhem is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or # the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# Fhem is distributed in the hope that it will be useful, # Fhem is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with fhem. If not, see <http://www.gnu.org/licenses/>. # along with fhem. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################## ##############################################################################
# #

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");