mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-08-11 22:10:14 +00:00
Recording the Severity of log message into xCAT logs (#5267)
- modify rsyslog conf and add "%syslogseverity-text:::uppercase%" to input the text Severity - remove duplicate Severity in log message - modify MsgUtils::trace for better performance and code structure
This commit is contained in:
@@ -897,42 +897,24 @@ sub trace() {
|
||||
if (($level eq "I") || ($level eq "i")) { $prefix = "INFO"; }
|
||||
if (($level eq "D") || ($level eq "d")) { $prefix = "DEBUG"; }
|
||||
|
||||
if (($level eq "E")
|
||||
|| ($level eq "e")
|
||||
|| ($level eq "I")
|
||||
|| ($level eq "i")
|
||||
|| ($level eq "W")
|
||||
|| ($level eq "w")) {
|
||||
my $msg = $prefix . " " . $logcontent;
|
||||
eval {
|
||||
openlog("xcat", "nofatal,pid", "local4");
|
||||
syslog("$prefix", $msg);
|
||||
closelog();
|
||||
};
|
||||
if ($@) {
|
||||
print "Error: Unable to log to syslog: $@\n";
|
||||
print "$msg\n";
|
||||
}
|
||||
return;
|
||||
return unless ($prefix); #unknown level, do nothing.
|
||||
|
||||
if (($verbose == 0) && ($prefix eq "DEBUG")) {
|
||||
my @tmp = xCAT::TableUtils->get_site_attribute("xcatdebugmode");
|
||||
my $xcatdebugmode = $tmp[0];
|
||||
return unless (($xcatdebugmode == 1) || ($xcatdebugmode == 2));
|
||||
}
|
||||
|
||||
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")) {
|
||||
my $msg = $prefix . " " . $logcontent;
|
||||
eval {
|
||||
openlog("xcat", "nofatal,pid", "local4");
|
||||
syslog("$prefix", $msg);
|
||||
closelog();
|
||||
};
|
||||
if ($@) {
|
||||
print "Error: Unable to log to syslog: $@\n";
|
||||
print "$msg\n";
|
||||
}
|
||||
}
|
||||
eval {
|
||||
openlog("xcat", "nofatal,pid", "local4");
|
||||
syslog("$prefix", $logcontent);
|
||||
closelog();
|
||||
};
|
||||
if ($@) {
|
||||
print "Error: Unable to log to syslog: $@\n";
|
||||
print "$prefix . $logcontent\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------
|
||||
|
@@ -844,14 +844,14 @@ sub do_udp_service { # This function opens up a UDP port
|
||||
#notify the client that its request is been processing
|
||||
my $ret=xCAT::NetworkUtils->send_tcp_msg($clientip,3001,"processing");
|
||||
if($ret){
|
||||
xCAT::MsgUtils->message("S", "INFO xcatd: fail to notify $clientip that its 'findme' request is been processing");
|
||||
xCAT::MsgUtils->message("S", "xcatd: fail to notify $clientip that its 'findme' request is been processing");
|
||||
}
|
||||
} elsif ($data =~ /^<xcat/) { # xml format
|
||||
store_fd({ data => $data, sockaddr => $clientip, sport => $sport }, $discoctl);
|
||||
#notify the client that its request is been processing
|
||||
my $ret=xCAT::NetworkUtils->send_tcp_msg($clientip,3001,"processing");
|
||||
if($ret){
|
||||
xCAT::MsgUtils->message("S", "INFO xcatd: fail to notify $clientip that its 'findme' request is been processing");
|
||||
xCAT::MsgUtils->message("S", "xcatd: fail to notify $clientip that its 'findme' request is been processing");
|
||||
}
|
||||
|
||||
} else { # for *now*, we'll do a tiny YAML subset
|
||||
@@ -1212,7 +1212,7 @@ unless ($cmdlog_svrpid) {
|
||||
if ($clientsock) { close($clientsock); }
|
||||
if (-e $cmdlogservicefile) { unlink("$cmdlogservicefile"); }
|
||||
if ($cmdlogsvrlistener) { close($cmdlogsvrlistener); }
|
||||
xCAT::MsgUtils->message("S", "INFO xcatd: 'Command log writer' process $$ is terminated by USR2 signal");
|
||||
xCAT::MsgUtils->message("S", "xcatd: 'Command log writer' process $$ is terminated by USR2 signal");
|
||||
exit(0);
|
||||
};
|
||||
|
||||
@@ -1222,7 +1222,7 @@ unless ($cmdlog_svrpid) {
|
||||
if ($clientsock) { close($clientsock); }
|
||||
if (-e $cmdlogservicefile) { unlink("$cmdlogservicefile"); }
|
||||
if ($cmdlogsvrlistener) { close($cmdlogsvrlistener); }
|
||||
xCAT::MsgUtils->message("S", "INFO xcatd: 'Command log writer' process $$ is terminated by TERM or INT signal");
|
||||
xCAT::MsgUtils->message("S", "xcatd: 'Command log writer' process $$ is terminated by TERM or INT signal");
|
||||
exit(0);
|
||||
};
|
||||
|
||||
@@ -1246,10 +1246,10 @@ unless ($cmdlog_svrpid) {
|
||||
$cmdlogfileswitch = 1;
|
||||
}
|
||||
if (!$trytime) {
|
||||
xCAT::MsgUtils->message("S", "INFO xcatd: 'Command log writer' process $$ get HUP signal, reopen commands.log file failed, send TERM signal to kill itself");
|
||||
xCAT::MsgUtils->message("S", "xcatd: 'Command log writer' process $$ get HUP signal, reopen commands.log file failed, send TERM signal to kill itself");
|
||||
kill 'INT', $$;
|
||||
} else {
|
||||
xCAT::MsgUtils->message("S", "INFO xcatd: 'Command log writer' process $$ get HUP signal, reopen commands.log file");
|
||||
xCAT::MsgUtils->message("S", "xcatd: 'Command log writer' process $$ get HUP signal, reopen commands.log file");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1260,7 +1260,7 @@ unless ($cmdlog_svrpid) {
|
||||
Listen => 8192);
|
||||
|
||||
if (not $cmdlogsvrlistener and open($cmdlogpidfile, "<", "$cmdlogservicefile")) {
|
||||
xCAT::MsgUtils->message("S", "INFO xcatd: 'Command log writer' process $$ is trying to get port $cmdlog_port");
|
||||
xCAT::MsgUtils->message("S", "xcatd: 'Command log writer' process $$ is trying to get port $cmdlog_port");
|
||||
my $pid = <$cmdlogpidfile>;
|
||||
if ($pid) {
|
||||
kill 'USR2', $pid;
|
||||
@@ -1319,7 +1319,7 @@ unless ($cmdlog_svrpid) {
|
||||
|
||||
if ($cmdlogfile) { close($cmdlogfile); }
|
||||
if ($cmdlogsvrlistener) { close($cmdlogsvrlistener); }
|
||||
xCAT::MsgUtils->message("S", "INFO xcatd: 'Command log writer' process $$ stop");
|
||||
xCAT::MsgUtils->message("S", "xcatd: 'Command log writer' process $$ stop");
|
||||
}
|
||||
|
||||
# ----used for command log end---------
|
||||
|
@@ -1,3 +1,3 @@
|
||||
$template xCATTraditionalFormat0,"%timegenerated% %HOSTNAME% %syslogtag% %msg:::drop-last-lf%\n"
|
||||
$template xCATTraditionalFormat0,"%timegenerated% %HOSTNAME% %syslogtag% %syslogseverity-text:::uppercase% %msg:::drop-last-lf%\n"
|
||||
:programname, isequal, "xcat" /var/log/xcat/cluster.log;xCATTraditionalFormat0
|
||||
:programname, startswith, "xcat." /var/log/xcat/cluster.log;xCATTraditionalFormat0
|
||||
|
@@ -1,3 +1,3 @@
|
||||
$template xCATTraditionalFormat9,"%timegenerated% %HOSTNAME% %syslogtag% %msg:::drop-last-lf%\n"
|
||||
$template xCATTraditionalFormat9,"%timegenerated% %HOSTNAME% %syslogtag% %syslogseverity-text:::uppercase% %msg:::drop-last-lf%\n"
|
||||
:fromhost-ip, !isequal, "127.0.0.1" /var/log/xcat/computes.log;xCATTraditionalFormat9
|
||||
& ~
|
||||
|
Reference in New Issue
Block a user