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