From 6ef4a081aa57aeee85ea280bd2fdd949956bbd35 Mon Sep 17 00:00:00 2001 From: Dave Brolley Date: Thu, 12 May 2011 16:39:02 -0400 Subject: [PATCH] Include the date & time in all compile server log messages. --- nsscommon.cxx | 19 +++++++++++++------ stap-serverd.cxx | 12 +++--------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/nsscommon.cxx b/nsscommon.cxx index e9af4b3b4..a8158cbbb 100644 --- a/nsscommon.cxx +++ b/nsscommon.cxx @@ -124,10 +124,17 @@ log_ok () void log (const string &msg) { + // What time is it? + time_t now; + time (& now); + string nowStr = ctime (& now); + // Remove the newline from the end of the time string. + nowStr.erase (nowStr.size () - 1, 1); + if (logfile.good ()) - logfile << msg << endl << flush; + logfile << nowStr << ": " << msg << endl << flush; else - clog << msg << endl << flush; + clog << nowStr << ": " << msg << endl << flush; } void @@ -1151,21 +1158,21 @@ cert_db_is_valid (const string &db_path, const string &nss_cert_name) CERTValidity &v = c->validity; char timeString[256]; if (format_cert_validity_time (v.notBefore, timeString, sizeof (timeString)) == 0) - log (_F(" Not Valid Before: %s", timeString)); + log (_F(" Not Valid Before: %s UTC", timeString)); if (format_cert_validity_time (v.notAfter, timeString, sizeof (timeString)) == 0) - log (_F(" Not Valid After: %s", timeString)); + log (_F(" Not Valid After: %s UTC", timeString)); // Now ask NSS to check the validity. if (cert_is_valid (c)) { // The cert is valid. One valid cert is enough. - log (_(" Certificate is valid")); + log (_("Certificate is valid")); valid_p = true; break; } // The cert is not valid. Look for another one. - log (_(" Certificate is not valid")); + log (_("Certificate is not valid")); } CERT_DestroyCertList (certs); diff --git a/stap-serverd.cxx b/stap-serverd.cxx index 6a1bfd8e5..5563fbb0a 100644 --- a/stap-serverd.cxx +++ b/stap-serverd.cxx @@ -33,7 +33,6 @@ extern "C" { #include #include #include -#include #include #include @@ -591,7 +590,7 @@ initialize (int argc, char **argv) { parse_options (argc, argv); pid_t pid = getpid (); - log (_F("===== compile server pid %d starting", pid)); + log (_F("===== compile server pid %d starting =====", pid)); // Where is the ssl certificate/key database? if (cert_db_path.empty ()) @@ -1390,7 +1389,6 @@ accept_connections (PRFileDesc *listenSocket, CERTCertificate *cert) PRFileDesc *tcpSocket; SECStatus secStatus; CERTCertDBHandle *dbHandle; - time_t now; dbHandle = CERT_GetDefaultCertDB (); @@ -1414,9 +1412,7 @@ accept_connections (PRFileDesc *listenSocket, CERTCertificate *cert) } /* Log the accepted connection. */ - time (& now); - log (_F("%sAccepted connection from %d.%d.%d.%d:%d", - ctime (& now), + log (_F("Accepted connection from %d.%d.%d.%d:%d", (addr.inet.ip ) & 0xff, (addr.inet.ip >> 8) & 0xff, (addr.inet.ip >> 16) & 0xff, @@ -1432,9 +1428,7 @@ accept_connections (PRFileDesc *listenSocket, CERTCertificate *cert) nsscommon_error (_("Error processing client request")); // Log the end of the request. - time (& now); - log (_F("%sRequest from %d.%d.%d.%d:%d complete", - ctime (& now), + log (_F("Request from %d.%d.%d.%d:%d complete", (addr.inet.ip ) & 0xff, (addr.inet.ip >> 8) & 0xff, (addr.inet.ip >> 16) & 0xff, -- 2.43.5