Skip to content

Commit

Permalink
Update logger again
Browse files Browse the repository at this point in the history
  • Loading branch information
davschneller committed Jul 8, 2024
1 parent 13ea706 commit 7124d97
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,23 +105,24 @@ class Logger {
*/
Logger(DebugType t, int rank) : stream(new Stream(t, rank)) {
auto timepoint = std::chrono::system_clock::now();
auto milli = std::chrono::duration_cast<std::chrono::milliseconds>(
timepoint.time_since_epoch())
.count();
auto milliTotal = std::chrono::duration_cast<std::chrono::milliseconds>(
timepoint.time_since_epoch())
.count();
auto milli = milliTotal % 1000;
time_t time = std::chrono::system_clock::to_time_t(timepoint);

stream->buffer << utils::TimeUtils::timeAsString("%F %T", time) << "."
<< StringUtils::padLeft(std::to_string(milli), 3, ' ');

switch (t) {
case LOG_DEBUG:
stream->buffer << " debug ";
stream->buffer << " debg ";
break;
case LOG_INFO:
stream->buffer << " info ";
break;
case LOG_WARNING:
stream->buffer << " warning ";
stream->buffer << " warn ";
break;
case LOG_ERROR:
stream->buffer << " error ";
Expand All @@ -132,9 +133,9 @@ class Logger {
}

if (rank >= 0) {
stream->buffer << rank << " ";
stream->buffer << rank << " :: ";
} else {
stream->buffer << "- ";
stream->buffer << "- :: ";
}
}
/**
Expand Down

0 comments on commit 7124d97

Please sign in to comment.