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

rozpracovano logovani na STDERR a Syslog. Neni zatim funkcni. Zmenena...

rozpracovano logovani na STDERR a Syslog. Neni zatim funkcni. Zmenena deklarace nekterych promennych z konfiguraku.
parent ce546a18
Branches
Tags
No related merge requests found
...@@ -28,3 +28,18 @@ $SSL_CA_FILE = "/etc/ssl/certs/tcs-ca-bundle.pem"; ...@@ -28,3 +28,18 @@ $SSL_CA_FILE = "/etc/ssl/certs/tcs-ca-bundle.pem";
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
$MAX_RCV_EVENTS_LIMIT = 6000; #consumes app. 250 MB of memory $MAX_RCV_EVENTS_LIMIT = 6000; #consumes app. 250 MB of memory
#-------------------------------------------------------------------------------
# Log options
#
# LOG_STDERR, LOG_SYSLOG - hide (0) or allow (1) error reporting on STDERR
# and/or to Syslog
# LOG_STDERR_VERBOSE, LOG_SYSLOG_VERBOSE - print only error message without
# a stack (0) or print debug info
# including err. message and stack (1)
#-------------------------------------------------------------------------------
$LOG_STDERR = 0;
$LOG_STDERR_VERBOSE = 0;
$LOG_SYSLOG = 1;
$LOG_SYSLOG_FACILITY = "local7";
$LOG_SYSLOG_VERBOSE = 1;
\ No newline at end of file
...@@ -25,6 +25,11 @@ sub loadConf ...@@ -25,6 +25,11 @@ sub loadConf
our $SSL_CERT_FILE = undef; our $SSL_CERT_FILE = undef;
our $SSL_CA_FILE = undef; our $SSL_CA_FILE = undef;
our $MAX_RCV_EVENTS_LIMIT = undef; our $MAX_RCV_EVENTS_LIMIT = undef;
our $LOG_STDERR = 0;
our $LOG_STDERR_VERBOSE = 0;
our $LOG_SYSLOG = 0;
our $LOG_SYSLOG_FACILITY = "local7";
our $LOG_SYSLOG_VERBOSE = 0;
# load set variables by user # load set variables by user
unless (do $conf_file) { unless (do $conf_file) {
...@@ -33,7 +38,7 @@ sub loadConf ...@@ -33,7 +38,7 @@ sub loadConf
# if $_ defined, it's retvalue of last statement of conf, for which we don't care # if $_ defined, it's retvalue of last statement of conf, for which we don't care
} }
return ($URI, $SSL_KEY_FILE, $SSL_CERT_FILE, $SSL_CA_FILE, $MAX_RCV_EVENTS_LIMIT); return ($URI, $SSL_KEY_FILE, $SSL_CERT_FILE, $SSL_CA_FILE, $MAX_RCV_EVENTS_LIMIT, $LOG_STDERR, $LOG_STDERR_VERBOSE, $LOG_SYSLOG, $LOG_SYSLOG_FACILITY, $LOG_SYSLOG_VERBOSE);
} # End of loadConf } # End of loadConf
1; 1;
...@@ -13,15 +13,34 @@ use SOAP::Lite; ...@@ -13,15 +13,34 @@ use SOAP::Lite;
use IO::Socket::SSL qw(debug1); use IO::Socket::SSL qw(debug1);
use SOAP::Transport::HTTP; use SOAP::Transport::HTTP;
use FindBin; use FindBin;
use Carp;
our $VERSION = "2.0"; our $VERSION = "2.0";
#----- global configuration variables -----------------------------------------
our $LOG_STDERR = 1;
our $LOG_STDERR_VERBOSE = 0;
our $LOG_SYSLOG = 0;
our $LOG_SYSLOG_FACILITY;
our $LOG_SYSLOG_VERBOSE = 0;
#------ end of configuration variables -----------------------------------------
# Retrieve stack info when handling errors? 0 is default, the precise value is
# computed as (LOG_STDERR_VERBOSE or LOG_SYSLOG_VERBOSE) after config file is
# read.
our $LOG_VERBOSE = 0;
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# errMsg - print error message and die # errMsg - print error message and die
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
sub errMsg sub errMsg
{ {
my $msg = shift; my $msg = "Error message: " . shift;
if ($LOG_VERBOSE) { # user wants to log debug information
$msg .= "\nStack info: " . Carp::longmess();
}
die($msg . "\n"); die($msg . "\n");
} # End of errMsg } # End of errMsg
...@@ -70,6 +89,10 @@ sub c2s ...@@ -70,6 +89,10 @@ sub c2s
} else { } else {
# deserialized response from server -> create SOAP envelope and data object # deserialized response from server -> create SOAP envelope and data object
my $response; my $response;
# test
errMsg("test error in c2s()");
eval { eval {
$response = $soap->deserializer->deserialize($result); $response = $soap->deserializer->deserialize($result);
} or errMsg($@ . "Received data: " . $result); } or errMsg($@ . "Received data: " . $result);
...@@ -98,7 +121,12 @@ sub getNewEvents ...@@ -98,7 +121,12 @@ sub getNewEvents
# read the config file # read the config file
require $libdir . "WardenClientConf.pm"; require $libdir . "WardenClientConf.pm";
my $conf_file = $etcdir . "warden-client.conf"; my $conf_file = $etcdir . "warden-client.conf";
my ($uri, $ssl_key_file, $ssl_cert_file, $ssl_ca_file, $max_rcv_events_limit) = WardenClientConf::loadConf($conf_file); my ($uri, $ssl_key_file, $ssl_cert_file, $ssl_ca_file, $max_rcv_events_limit);
($uri, $ssl_key_file, $ssl_cert_file, $ssl_ca_file, $max_rcv_events_limit, $LOG_STDERR, $LOG_STDERR_VERBOSE, $LOG_SYSLOG, $LOG_SYSLOG_FACILITY, $LOG_SYSLOG_VERBOSE) = WardenClientConf::loadConf($conf_file);
$LOG_VERBOSE = ($LOG_STDERR_VERBOSE or $LOG_SYSLOG_VERBOSE);
# test
# errMsg("testovaci error\n");
# set name of ID file for each client aplication # set name of ID file for each client aplication
my $caller_name = $FindBin::Script; my $caller_name = $FindBin::Script;
...@@ -178,7 +206,18 @@ sub getNewEvents ...@@ -178,7 +206,18 @@ sub getNewEvents
} }
} # End of eval block } # End of eval block
or do { or do {
print STDERR "Warden-client unexpected end in eval block: " . $@ . "\n";
if ($LOG_STDERR) {
# TODO: rozlisovat VERBOSE (STDERR vs. Syslog)?
print STDERR "(STDERR)Warden-client unexpected end in eval block.\n" . $@ . "\n";
}
if ($LOG_SYSLOG) {
# TODO: rozlisovat VERBOSE (STDERR vs. Syslog)?
#TODO: zapis do syslogu, ne STDERR
print STDERR "(SYSLOG)Warden-client unexpected end in eval block.\n" . $@ . "\n";
}
return; return;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment