Skip to content

Commit

Permalink
Rename ORTTraceLoggingKeyword and more lint NITs
Browse files Browse the repository at this point in the history
  • Loading branch information
ivberg committed Jan 9, 2024
1 parent be85e9d commit 7e387c6
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 20 deletions.
6 changes: 3 additions & 3 deletions include/onnxruntime/core/common/logging/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ struct Category {
};

/// <summary>
/// TraceLogging keywords for categories of dynamic logging enablement
/// ORT TraceLogging keywords for categories of dynamic logging enablement
/// </summary>
enum class TraceLoggingKeyword : uint64_t {
enum class ORTTraceLoggingKeyword : uint64_t {
Session = 0x1, // ORT Session TraceLoggingWrite
Logs = 0x2, // LOGS() Macro ORT logs. Pair with an appropiate level depending on detail required
Logs = 0x2, // LOGS() Macro ORT logs. Pair with an appropriate level depending on detail required
Reserved1 = 0x4, // Reserved if we want to add some specific sub-categories instead of just LOGS() or other uses
Reserved2 = 0x8,
Reserved3 = 0x10,
Expand Down
3 changes: 2 additions & 1 deletion onnxruntime/core/common/logging/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ std::unique_ptr<ISink> EnhanceLoggerWithEtw(std::unique_ptr<ISink> existingLogge
Severity OverrideLevelWithEtw(Severity originalSeverity) {
#ifdef _WIN32
auto& manager = logging::EtwRegistrationManager::Instance();
if (manager.IsEnabled() && (manager.Keyword() & static_cast<ULONGLONG>(onnxruntime::logging::TraceLoggingKeyword::Logs)) != 0) {
if (manager.IsEnabled() &&
(manager.Keyword() & static_cast<ULONGLONG>(onnxruntime::logging::ORTTraceLoggingKeyword::Logs)) != 0) {
return manager.MapLevelToSeverity();
}
#endif // _WIN32
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/framework/execution_providers.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ExecutionProviders {
TraceLoggingWrite(
telemetry_provider_handle,
"ProviderOptions",
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::TraceLoggingKeyword::Session)),
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::ORTTraceLoggingKeyword::Session)),
TraceLoggingLevel(WINEVENT_LEVEL_INFO),
TraceLoggingString(provider_id.c_str(), "ProviderId"),
TraceLoggingString(config_pair.first.c_str(), "Key"),
Expand Down
14 changes: 7 additions & 7 deletions onnxruntime/core/platform/windows/logging/etw_sink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ void EtwSink::SendImpl(const Timestamp& timestamp, const std::string& logger_id,
// TraceLoggingWrite requires (painfully) a compile time constant for the TraceLoggingLevel,
// forcing us to use an ugly macro for the call.
#define ETW_EVENT_NAME "ONNXRuntimeLogEvent"
#define TRACE_LOG_WRITE(level) \
TraceLoggingWrite(etw_provider_handle, ETW_EVENT_NAME, \
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::TraceLoggingKeyword::Logs)), \
TraceLoggingLevel(level), \
TraceLoggingString(logger_id.c_str(), "logger"), \
TraceLoggingString(message.Category(), "category"), \
TraceLoggingString(message.Location().ToString().c_str(), "location"), \
#define TRACE_LOG_WRITE(level) \
TraceLoggingWrite(etw_provider_handle, ETW_EVENT_NAME, \
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::ORTTraceLoggingKeyword::Logs)), \
TraceLoggingLevel(level), \
TraceLoggingString(logger_id.c_str(), "logger"), \
TraceLoggingString(message.Category(), "category"), \
TraceLoggingString(message.Location().ToString().c_str(), "location"), \
TraceLoggingString(message.Message().c_str(), "message"))

const auto severity{message.Severity()};
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/platform/windows/telemetry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void WindowsTelemetry::LogSessionCreation(uint32_t session_id, int64_t ir_versio
TraceLoggingBool(true, "UTCReplace_AppSessionGuid"),
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage),
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::TraceLoggingKeyword::Session)),
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::ORTTraceLoggingKeyword::Session)),
TraceLoggingLevel(WINEVENT_LEVEL_INFO),
// Telemetry info
TraceLoggingUInt8(0, "schemaVersion"),
Expand Down
4 changes: 2 additions & 2 deletions onnxruntime/core/providers/qnn/builder/qnn_backend_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ Status QnnBackendManager::ExtractBackendProfilingInfo() {
auto& provider = env.GetTelemetryProvider();
if (provider.IsEnabled()) {
auto keyword = provider.Keyword();
if ((keyword & static_cast<uint64_t>(onnxruntime::logging::TraceLoggingKeyword::Profiling)) != 0) {
if ((keyword & static_cast<uint64_t>(onnxruntime::logging::ORTTraceLoggingKeyword::Profiling)) != 0) {
tracelogging_provider_ep_enabled = true;
}
}
Expand Down Expand Up @@ -1033,7 +1033,7 @@ void QnnBackendManager::LogQnnProfileEventAsTraceLogging(
TraceLoggingWrite(
telemetry_provider_handle,
"QNNProfilingEvent",
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::TraceLoggingKeyword::Profiling)),
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::ORTTraceLoggingKeyword::Profiling)),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE),
TraceLoggingValue(timestamp, "Timestamp"),
TraceLoggingString(message.c_str(), "Message"),
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/providers/qnn/qnn_execution_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ QNNExecutionProvider::QNNExecutionProvider(const ProviderOptions& provider_optio
if (provider.IsEnabled()) {
auto level = provider.Level();
auto keyword = provider.Keyword();
if ((keyword & static_cast<uint64_t>(onnxruntime::logging::TraceLoggingKeyword::Profiling)) != 0) {
if ((keyword & static_cast<uint64_t>(onnxruntime::logging::ORTTraceLoggingKeyword::Profiling)) != 0) {
if (level != 0) {
if (level == 5) {
LOGS_DEFAULT(INFO) << "Overriding profiling to basic based on ETW level: " << static_cast<int>(level);
Expand Down
6 changes: 3 additions & 3 deletions onnxruntime/core/session/inference_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ void InferenceSession::TraceSessionOptions(const SessionOptions& session_options
#ifdef _WIN32
TraceLoggingWrite(telemetry_provider_handle,
"SessionOptions",
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::TraceLoggingKeyword::Session)),
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::ORTTraceLoggingKeyword::Session)),
TraceLoggingLevel(WINEVENT_LEVEL_INFO),
TraceLoggingUInt8(static_cast<UINT8>(session_options.execution_mode), "execution_mode"),
TraceLoggingUInt8(static_cast<UINT8>(session_options.execution_order), "execution_order"),
Expand All @@ -501,7 +501,7 @@ void InferenceSession::TraceSessionOptions(const SessionOptions& session_options
TraceLoggingWrite(
telemetry_provider_handle,
"SessionOptions_IntraOrtThreadPoolParams",
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::TraceLoggingKeyword::Session)),
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::ORTTraceLoggingKeyword::Session)),
TraceLoggingLevel(WINEVENT_LEVEL_INFO),
TraceLoggingInt32(session_options.intra_op_param.thread_pool_size, "thread_pool_size"),
TraceLoggingBoolean(session_options.intra_op_param.auto_set_affinity, "auto_set_affinity"),
Expand All @@ -515,7 +515,7 @@ void InferenceSession::TraceSessionOptions(const SessionOptions& session_options
TraceLoggingWrite(
telemetry_provider_handle,
"SessionOptions_ConfigEntry",
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::TraceLoggingKeyword::Session)),
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::ORTTraceLoggingKeyword::Session)),
TraceLoggingLevel(WINEVENT_LEVEL_INFO),
TraceLoggingString(config_pair.first.c_str(), "Key"),
TraceLoggingString(config_pair.second.c_str(), "Value"));
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/session/provider_registration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ ORT_API_STATUS_IMPL(OrtApis::SessionOptionsAppendExecutionProvider,
TraceLoggingWrite(
telemetry_provider_handle,
"ProviderOptionsAppendExecutionProvider",
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::TraceLoggingKeyword::Session)),
TraceLoggingKeyword(static_cast<uint64_t>(onnxruntime::logging::ORTTraceLoggingKeyword::Session)),
TraceLoggingLevel(WINEVENT_LEVEL_INFO),
TraceLoggingString(provider_name, "ProviderName"),
TraceLoggingString(config_pair.first.c_str(), "Key"),
Expand Down

0 comments on commit 7e387c6

Please sign in to comment.