Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions projects/miopen/src/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_ENABLE_LOGGING_MPMT)
/// Add timestamps to each log line.
/// Not useful with multi-process/multi-threaded apps.
MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_ENABLE_LOGGING_ELAPSED_TIME)
/// Add timestamps to each log line.
MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_ENABLE_LOGGING_DATE_TIME)
Comment thread
JonathanLichtnerAMD marked this conversation as resolved.

/// See LoggingLevel in the header.
MIOPEN_DECLARE_ENV_VAR_UINT64(MIOPEN_LOG_LEVEL)
Expand Down Expand Up @@ -117,6 +119,18 @@ inline float GetTimeDiff()
return rv;
}

inline std::string GetDateTimeMs()
{
auto now = std::chrono::system_clock::now();
Comment thread
cderb marked this conversation as resolved.
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()) % 1000;
auto now_t = std::chrono::system_clock::to_time_t(now);
std::tm local_time = *std::localtime(&now_t);
Comment thread
cderb marked this conversation as resolved.
Outdated
std::ostringstream time_s;
time_s << std::put_time(&local_time, "%Y-%m-%d %H:%M:%S");
time_s << ":"<< std::setfill('0') << std::setw(3) << ms.count();
Comment thread
cderb marked this conversation as resolved.
Outdated
return time_s.str();
}

} // namespace

bool IsLoggingDebugQuiet()
Expand Down Expand Up @@ -195,6 +209,10 @@ std::string LoggingPrefix()
{
ss << std::fixed << std::setprecision(3) << std::setw(8) << GetTimeDiff();
}
if(env::enabled(MIOPEN_ENABLE_LOGGING_DATE_TIME))
{
ss << " (" << GetDateTimeMs() << ")";
Comment thread
cderb marked this conversation as resolved.
}
ss << ": ";
return ss.str();
}
Expand Down