diff --git a/include/onnxruntime/ep/adapter/logging.h b/include/onnxruntime/ep/adapter/logging.h index e001df5db23f9..6e4b984611161 100644 --- a/include/onnxruntime/ep/adapter/logging.h +++ b/include/onnxruntime/ep/adapter/logging.h @@ -34,6 +34,13 @@ struct Logger { message); } + private: + Ort::Logger logger_; +}; + +class LoggingManager final { + public: + static bool HasDefaultLogger() { return nullptr != instance_; } static const Logger& DefaultLogger() { return *instance_; } static void CreateDefaultLogger(const OrtLogger* logger) { instance_ = new Logger(logger); @@ -44,7 +51,6 @@ struct Logger { } private: - Ort::Logger logger_; inline static Logger* instance_ = nullptr; }; @@ -104,7 +110,7 @@ inline detail::LoggerCapture CreateMessageCapture( // Undefine and redefine logging macros #undef LOGS_DEFAULT_CATEGORY #define LOGS_DEFAULT_CATEGORY(severity, category) \ - LOGS_CATEGORY(::onnxruntime::ep::adapter::Logger::DefaultLogger(), severity, category) + LOGS_CATEGORY(::onnxruntime::ep::adapter::LoggingManager::DefaultLogger(), severity, category) #undef CREATE_MESSAGE #define CREATE_MESSAGE(logger, severity, category, datatype) \ diff --git a/include/onnxruntime/ep/adapters.h b/include/onnxruntime/ep/adapters.h index a33cb4a456de6..306f009ff01f7 100644 --- a/include/onnxruntime/ep/adapters.h +++ b/include/onnxruntime/ep/adapters.h @@ -42,6 +42,7 @@ using DataTransferManager = onnxruntime::ep::adapter::DataTransferManager; \ namespace logging { \ using Logger = onnxruntime::ep::adapter::Logger; \ + using LoggingManager = onnxruntime::ep::adapter::LoggingManager; \ } namespace onnxruntime {