Skip to content

Commit c07ece3

Browse files
authored
[EP Plugin Adapter] support LoggingManager::HasDefaultLogger() (microsoft#27587)
### Description Add support for `LoggingManager::HasDefaultLogger()`.
1 parent 9597f8a commit c07ece3

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

include/onnxruntime/ep/adapter/logging.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ struct Logger {
3434
message);
3535
}
3636

37+
private:
38+
Ort::Logger logger_;
39+
};
40+
41+
class LoggingManager final {
42+
public:
43+
static bool HasDefaultLogger() { return nullptr != instance_; }
3744
static const Logger& DefaultLogger() { return *instance_; }
3845
static void CreateDefaultLogger(const OrtLogger* logger) {
3946
instance_ = new Logger(logger);
@@ -44,7 +51,6 @@ struct Logger {
4451
}
4552

4653
private:
47-
Ort::Logger logger_;
4854
inline static Logger* instance_ = nullptr;
4955
};
5056

@@ -104,7 +110,7 @@ inline detail::LoggerCapture CreateMessageCapture(
104110
// Undefine and redefine logging macros
105111
#undef LOGS_DEFAULT_CATEGORY
106112
#define LOGS_DEFAULT_CATEGORY(severity, category) \
107-
LOGS_CATEGORY(::onnxruntime::ep::adapter::Logger::DefaultLogger(), severity, category)
113+
LOGS_CATEGORY(::onnxruntime::ep::adapter::LoggingManager::DefaultLogger(), severity, category)
108114

109115
#undef CREATE_MESSAGE
110116
#define CREATE_MESSAGE(logger, severity, category, datatype) \

include/onnxruntime/ep/adapters.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
using DataTransferManager = onnxruntime::ep::adapter::DataTransferManager; \
4343
namespace logging { \
4444
using Logger = onnxruntime::ep::adapter::Logger; \
45+
using LoggingManager = onnxruntime::ep::adapter::LoggingManager; \
4546
}
4647

4748
namespace onnxruntime {

0 commit comments

Comments
 (0)