Nice timestamp format using Howard Hinnant's header only date C++ library

Signed-off-by: Mihai Stefanescu <mihai.t.gh.stefanescu@gmail.com>
This commit is contained in:
Mihai Stefanescu 2018-06-15 20:22:01 +03:00 committed by Stefan Andritoiu
parent 422b6926b5
commit 1018ffea16
2 changed files with 8437 additions and 4 deletions

8433
include/date.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -24,12 +24,12 @@
#pragma once #pragma once
#include <chrono>
#include <fstream> #include <fstream>
#include <mutex> #include <mutex>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <thread> #include <thread>
#include "date.h"
/* Helper macro for logger utility class. */ /* Helper macro for logger utility class. */
#define UPM_LOG(log_level) \ #define UPM_LOG(log_level) \
@ -67,10 +67,10 @@ class UPM_LOGGER
std::ofstream& std::ofstream&
log(UpmLogLevel level = LOG_ERROR) log(UpmLogLevel level = LOG_ERROR)
{ {
using namespace std::chrono; using namespace date;
_logStream << "UPM - " _logStream << "UPM - "
<< duration_cast<nanoseconds>(system_clock::now().time_since_epoch()).count(); << std::chrono::system_clock::now();
_logStream << " [" << getLogLevelName(level) << "] "; _logStream << " [" << getLogLevelName(level) << "] ";
return _logStream; return _logStream;