53 namespace onnxruntime {
57 using Timestamp = std::chrono::time_point<std::chrono::system_clock>;
62 constexpr
bool vlog_enabled =
false;
125 int default_max_vlog_level = -1);
143 Severity min_severity,
bool filter_user_data,
int max_vlog_level = -1);
183 const char* format_str, ...);
203 void CreateDefaultLogger(const std::
string& logger_id);
205 std::unique_ptr<
ISink> sink_;
206 const
Severity default_min_severity_;
207 const
bool default_filter_user_data_;
208 const
int default_max_vlog_level_;
209 bool owns_default_logger_;
211 static
Logger* s_default_logger_;
214 const std::chrono::time_point<std::chrono::high_resolution_clock> high_res;
215 const std::chrono::time_point<std::chrono::system_clock> system;
216 const std::chrono::minutes localtime_offset_from_utc;
219 static const Epochs& GetEpochs() noexcept;
238 : logging_manager_{&loggingManager},
241 filter_user_data_{filter_user_data},
242 max_vlog_level_{vlog_level} {
263 void SetVerbosity(
int vlog_level) noexcept { max_vlog_level_ = vlog_level; }
287 logging_manager_->Log(id_, message);
295 logging_manager_->SendProfileEvent(eventRecord);
302 const bool filter_user_data_;
307 if (s_default_logger_ ==
nullptr) {
309 ORT_THROW(
"Attempt to use DefaultLogger but none has been registered.");
312 return *s_default_logger_;
316 if (s_default_logger_ ==
nullptr) {
318 ORT_THROW(
"Attempt to use DefaultLogger but none has been registered.");
325 if (s_default_logger_ ==
nullptr) {
327 ORT_THROW(
"Attempt to use DefaultLogger but none has been registered.");
333 inline Timestamp LoggingManager::GetTimestamp() const noexcept {
334 static const Epochs& epochs = GetEpochs();
336 const auto high_res_now = std::chrono::high_resolution_clock::now();
337 return std::chrono::time_point_cast<std::chrono::system_clock::duration>(
338 epochs.system + (high_res_now - epochs.high_res) + epochs.localtime_offset_from_utc);
Logger(const LoggingManager &loggingManager, std::string id, Severity severity, bool filter_user_data, int vlog_level)
GLuint GLsizei const GLchar * message
void Log(const std::string &logger_id, const Capture &message) const
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
std::unique_ptr< Logger > CreateLogger(const std::string &logger_id)
GLsizei const GLchar *const * string
void SendProfileEvent(profiling::EventRecord &eventRecord) const
LoggingManager(std::unique_ptr< ISink > sink, Severity default_min_severity, bool default_filter_user_data, InstanceType instance_type, const std::string *default_logger_id=nullptr, int default_max_vlog_level=-1)
void SendProfileEvent(profiling::EventRecord &eventRecord) const
static void SetDefaultLoggerSeverity(Severity severity)
Contains potentially sensitive user data.
unsigned int GetThreadId()
Temporal instance. CreateLogger(...) should be used, however DefaultLogger() will NOT be provided via...
ORTTraceLoggingKeyword
ORT TraceLogging keywords for categories of dynamic logging enablement
unsigned int GetProcessId()
Severity OverrideLevelWithEtw(Severity originalSeverity)
static const Logger & DefaultLogger()
static const char * onnxruntime
General output.
The logging manager. Owns the log sink and potentially provides a default Logger instance. Provides filtering based on a minimum LogSeverity level, and of messages with DataType::User if enabled.
std::chrono::time_point< std::chrono::system_clock > Timestamp
void SetVerbosity(int vlog_level) noexcept
std::unique_ptr< ISink > EnhanceLoggerWithEtw(std::unique_ptr< ISink > existingLogger, logging::Severity originalSeverity, logging::Severity etwSeverity)
#define ORT_ATTRIBUTE_UNUSED
static void SetDefaultLoggerVerbosity(int vlog_level)
Severity GetSeverity() const noexcept
void SetSeverity(Severity severity) noexcept
bool OutputIsEnabled(Severity severity, DataType data_type) const noexcept
void Log(const Capture &message) const
static bool HasDefaultLogger()
static const char * System
Log output regarding interactions with the host system.
int VLOGMaxLevel() const noexcept
static std::exception LogFatalAndCreateException(const char *category, const CodeLocation &location, const char *format_str,...)
Default instance of LoggingManager that should exist for the lifetime of the program.