Skip to content
Snippets Groups Projects
Commit 4ceb1a82 authored by Jan Soukal's avatar Jan Soukal
Browse files

Sjednoceni warningu a erroru v ramci ukolu #596

parent a0c003b6
No related branches found
No related tags found
No related merge requests found
...@@ -17,37 +17,16 @@ use SOAP::Transport::HTTP; ...@@ -17,37 +17,16 @@ use SOAP::Transport::HTTP;
our $VERSION = "2.2"; our $VERSION = "2.2";
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# warnMsg - prints warning (to STDERR and/or Syslog) and returns 1 # errMsg - prints error msg and returns undef or prints warning and returns 1
#-------------------------------------------------------------------------------
sub warnMsg
{
my $msg = shift;
# print warning to STDERR?
if ($WardenClientConf::LOG_STDERR) {
print STDERR $msg . "\n";
}
# print warning to Syslog?
if ($WardenClientConf::LOG_SYSLOG) {
openlog("Warden-client:", "pid", "$WardenClientConf::LOG_SYSLOG_FACILITY");
syslog("warn|$WardenClientConf::LOG_SYSLOG_FACILITY", $msg . "\n");
closelog();
}
return 1;
} # end of warnMsg()
#-------------------------------------------------------------------------------
# errMsg - print error message and returns undef
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
sub errMsg sub errMsg
{ {
my $msg = shift; my $msg = shift;
my $type = shift;
defined $type or $type = "err"; # default type is err. Other: warn
# is Verbose logging mode enabled? # is this error report and is Verbose logging mode enabled?
if ($WardenClientConf::LOG_VERBOSE) { # user wants to log debug information if (($type eq "err") && ($WardenClientConf::LOG_VERBOSE)) { # user wants to log debug information
$msg .= "\nStack info: " . Carp::longmess(); $msg .= "\nStack info: " . Carp::longmess();
} }
...@@ -59,11 +38,16 @@ sub errMsg ...@@ -59,11 +38,16 @@ sub errMsg
# log into Syslog? # log into Syslog?
if ($WardenClientConf::LOG_SYSLOG) { if ($WardenClientConf::LOG_SYSLOG) {
openlog("Warden-client:", "pid", "$WardenClientConf::LOG_SYSLOG_FACILITY"); openlog("Warden-client:", "pid", "$WardenClientConf::LOG_SYSLOG_FACILITY");
syslog("err|$WardenClientConf::LOG_SYSLOG_FACILITY", $msg . "\n"); syslog("$type|$WardenClientConf::LOG_SYSLOG_FACILITY", $msg . "\n");
closelog(); closelog();
} }
return; if ($type eq 'warn') { # case of 'warn'
return 1;
} else { # case of 'err'
return;
}
} # End of errMsg } # End of errMsg
......
...@@ -10,13 +10,6 @@ package WardenClientConf; ...@@ -10,13 +10,6 @@ package WardenClientConf;
use strict; use strict;
# (for more information se issue #596) - Should be removed in Warden client 3.0
# Array containg event attributes that has already been reported to user as obsolete.
our %report_obsolete = ();
$report_obsolete{'priority'} = 1;
$report_obsolete{'timeout'} = 1;
# end of issue #596
# preset of default variables # preset of default variables
our $URI = undef; our $URI = undef;
our $SSL_KEY_FILE = undef; our $SSL_KEY_FILE = undef;
......
...@@ -54,21 +54,15 @@ sub saveNewEvent ...@@ -54,21 +54,15 @@ sub saveNewEvent
# Checking for obsolete attributes priority or timeout. If not default or 'undef' values are found, print out warning. # Checking for obsolete attributes priority or timeout. If not default or 'undef' values are found, print out warning.
# check if obsolete event attribute Priority is used # check if obsolete event attribute Priority is used
if ($WardenClientConf::report_obsolete{'priority'} && (defined $priority) && ($priority >= 1)) { if ((defined $priority) && ($priority >= 1)) {
# print warning # print warning
WardenClientCommon::warnMsg('Event attribute "Priority" is now obsolete and will be removed in Warden client 3.0'); WardenClientCommon::errMsg('Event attribute "Priority" is now obsolete and will be removed in Warden client 3.0', 'warn');
# update WardenClientConf::report_obsolete reference to avoid multiple reports regarding one event attribute
$WardenClientConf::report_obsolete{'priority'} = 0;
} }
# check if obsolete event attribute Timeout is used # check if obsolete event attribute Timeout is used
if ($WardenClientConf::report_obsolete{'timeout'} && (defined $timeout) && ($timeout >= 0)) { if ((defined $timeout) && ($timeout >= 0)) {
# print warning # print warning
WardenClientCommon::warnMsg('Event attribute "Timeout" is now obsolete and will be removed in Warden client 3.0'); WardenClientCommon::errMsg('Event attribute "Timeout" is now obsolete and will be removed in Warden client 3.0', 'warn');
# update WardenClientConf::report_obsolete reference to avoid multiple reports regarding one event attribute
$WardenClientConf::report_obsolete{'timeout'} = 0;
} }
# end of Issue #596 # end of Issue #596
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment