From 6d8081142bb1026fe0580ca07643a9efe939cb00 Mon Sep 17 00:00:00 2001 From: Bin Xu Date: Tue, 27 Mar 2018 14:04:51 +0800 Subject: [PATCH] workaround ($4929) the MsgUtil.pm first to make sure xcatd will not crash when /dev/log is not ready. (#4974) --- perl-xCAT/xCAT/MsgUtils.pm | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/perl-xCAT/xCAT/MsgUtils.pm b/perl-xCAT/xCAT/MsgUtils.pm index 18a5f7f3b..4e3bf292c 100644 --- a/perl-xCAT/xCAT/MsgUtils.pm +++ b/perl-xCAT/xCAT/MsgUtils.pm @@ -486,7 +486,8 @@ sub message if ($errstr) { print $stdouterrf - "Unable to log $rsp to syslog because of $errstr\n"; + "Error: Unable to log to syslog: $errstr\n"; + print "$rsp\n"; } } @@ -896,9 +897,6 @@ sub trace() { if (($level eq "I") || ($level eq "i")) { $prefix = "INFO"; } if (($level eq "D") || ($level eq "d")) { $prefix = "DEBUG"; } - my @tmp = xCAT::TableUtils->get_site_attribute("xcatdebugmode"); - my $xcatdebugmode = $tmp[0]; - if (($level eq "E") || ($level eq "e") || ($level eq "I") @@ -911,8 +909,15 @@ sub trace() { syslog("$prefix", $msg); closelog(); }; + if ($@) { + print "Error: Unable to log to syslog: $@\n"; + print "$msg\n"; + } + return; } + my @tmp = xCAT::TableUtils->get_site_attribute("xcatdebugmode"); + my $xcatdebugmode = $tmp[0]; if (($level eq "D") || ($level eq "d")) { if (($verbose == 1) || ($xcatdebugmode eq "1") || ($xcatdebugmode eq "2")) { @@ -921,6 +926,10 @@ sub trace() { openlog("xcat", "nofatal,pid", "local4"); syslog("$prefix", $msg); closelog(); + }; + if ($@) { + print "Error: Unable to log to syslog: $@\n"; + print "$msg\n"; } } }