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
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);
#include <fcntl.h>
#include <sys/resource.h>
#include <sys/stat.h>
-#include <sys/time.h>
#include <sys/utsname.h>
#include <nspr.h>
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 ())
PRFileDesc *tcpSocket;
SECStatus secStatus;
CERTCertDBHandle *dbHandle;
- time_t now;
dbHandle = CERT_GetDefaultCertDB ();
}
/* 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,
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,