Skip to content
Snippets Groups Projects
Commit 2e0d6067 authored by Florian Schmaus's avatar Florian Schmaus
Browse files

Merge branch 'use-system-clock' into 'master'

[log] Use system_clock instead of high_resolution_clock

See merge request !309
parents 2b5545de f32104a4
No related branches found
No related tags found
1 merge request!309[log] Use system_clock instead of high_resolution_clock
Pipeline #75704 passed
......@@ -24,12 +24,10 @@ using emper::io::GlobalIoContext;
namespace emper::log {
static void add_timestamp_to(std::ostringstream& logMessage) {
#if defined __GLIBCXX__
static const long NanosInAMinute = 60L * 1000 * 1000 * 1000;
using clock = std::chrono::system_clock;
auto now = std::chrono::high_resolution_clock::now();
auto now_time_t = std::chrono::high_resolution_clock::to_time_t(now);
auto now = clock::now();
auto now_time_t = clock::to_time_t(now);
const std::tm* now_localtime = [&now_time_t] {
if constexpr (emper::LOG_TIMESTAMP == emper::LogTimeStamp::utc) {
......@@ -52,11 +50,9 @@ static void add_timestamp_to(std::ostringstream& logMessage) {
auto time_since_epoch = now_nanos.time_since_epoch();
long time_since_epoch_long = time_since_epoch.count();
const long NanosInAMinute = 60L * 1000 * 1000 * 1000;
long remaining_nanos = time_since_epoch_long % NanosInAMinute;
logMessage << remaining_nanos;
#else
logMessage << "UNKN_TIME";
#endif
}
static std::mutex log_mutex;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment