Commit f610dc43 authored by Mike Hibler's avatar Mike Hibler
Browse files

Bug Fix: time stamp child debug messages.

parent 205fa4b9
...@@ -1796,6 +1796,15 @@ sub info($) { ...@@ -1796,6 +1796,15 @@ sub info($) {
print strftime("%b %e %H:%M:%S", localtime) . " [$$]: $message"; print strftime("%b %e %H:%M:%S", localtime) . " [$$]: $message";
} }
# XXX for child: stderr goes to log (stdout goes to parent)
sub cinfo($) {
my $message = shift;
# Print out log entries like this:
# Sep 20 09:36:00 [238]: Reloading state from database
print STDERR strftime("%b %e %H:%M:%S", localtime) . " [$$]: $message";
}
sub restart_wrap { $sigrestart=1; } sub restart_wrap { $sigrestart=1; }
# This gets called if we catch a signal USR1 # This gets called if we catch a signal USR1
...@@ -1933,13 +1942,13 @@ sub StartEvents() ...@@ -1933,13 +1942,13 @@ sub StartEvents()
# Plain exit in the child. # Plain exit in the child.
$SIG{TERM} = sub { $SIG{TERM} = sub {
print STDERR "Caught a TERM in child. Exiting ...\n"; cinfo("Caught a TERM in child. Exiting ...\n");
exit(0); exit(0);
}; };
# Make sure this child starts writing into the new logfile. # Make sure this child starts writing into the new logfile.
$SIG{USR2} = sub { $SIG{USR2} = sub {
print STDERR "Caught a USR2 in child\n"; cinfo("Caught a USR2 in child\n");
# Only STDERR can be redirected to the newfile. STDOUT is writing # Only STDERR can be redirected to the newfile. STDOUT is writing
# to the parent process. # to the parent process.
close(STDERR); close(STDERR);
...@@ -1948,7 +1957,7 @@ sub StartEvents() ...@@ -1948,7 +1957,7 @@ sub StartEvents()
$OUTPUT_AUTOFLUSH = 1; $OUTPUT_AUTOFLUSH = 1;
# restore default output. # restore default output.
select STDOUT; select STDOUT;
print STDERR "Opened new logfile in child\n"; cinfo("Opened new logfile in child\n");
}; };
# #
...@@ -1971,8 +1980,7 @@ sub StubHandleEvent($$$) { ...@@ -1971,8 +1980,7 @@ sub StubHandleEvent($$$) {
# #
print "OBJTYPE='$objtype', OBJNAME='$objname', EVENTTYPE='$eventtype'\n"; print "OBJTYPE='$objtype', OBJNAME='$objname', EVENTTYPE='$eventtype'\n";
if (1) { if (1) {
print STDERR cinfo("OBJTYPE='$objtype', OBJNAME='$objname', EVENTTYPE='$eventtype'\n");
"OBJTYPE='$objtype', OBJNAME='$objname', EVENTTYPE='$eventtype'\n";
} }
return 0; return 0;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment