mirror of
https://github.com/znc/znc.git
synced 2026-05-10 07:14:43 +02:00
Rewrite printing timestamps in znc -D
Previous commit doing it was 0f739de2c0
This commit is contained in:
@@ -7,6 +7,9 @@
|
||||
*/
|
||||
|
||||
#include <znc/ZNCDebug.h>
|
||||
#include <iostream>
|
||||
#include <sys/time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
bool CDebug::stdoutIsTTY = true;
|
||||
bool CDebug::debug =
|
||||
@@ -15,3 +18,17 @@ bool CDebug::debug =
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
|
||||
CDebugStream::~CDebugStream() {
|
||||
timeval tTime;
|
||||
gettimeofday(&tTime, NULL);
|
||||
time_t tSec = (time_t)tTime.tv_sec; // some systems (e.g. openbsd) define tv_sec as long int instead of time_t
|
||||
tm tM;
|
||||
tzset();// localtime_r requires this
|
||||
localtime_r(&tSec, &tM);
|
||||
char sTime[20] = {};
|
||||
strftime(sTime, sizeof(sTime), "%Y-%m-%d %H:%M:%S", &tM);
|
||||
char sUsec[7] = {};
|
||||
snprintf(sUsec, sizeof(sUsec), "%06lu", (unsigned long int)tTime.tv_usec);
|
||||
std::cout << "[" << sTime << "." << sUsec << "] " << CString(this->str()).Escape_n(CString::EDEBUG) << std::endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user