Add getter/setter of C# OrtEnv log level - #13402
Conversation
| * | ||
| * \since Version 1.13. | ||
| */ | ||
| ORT_API2_STATUS(UpdateEnvWithCustomLogLevel, OrtLoggingLevel log_severity_level, _In_ const OrtEnv* ort_env); |
There was a problem hiding this comment.
You can't really have OrtEnv passed as const when you've an API to update it :-).
There was a problem hiding this comment.
Thanks for pointing out! That has been fixed
There was a problem hiding this comment.
Please, add C++ API so users do not have to go to C back and forth.
There was a problem hiding this comment.
C++ API has been added in latest commit as well. Thanks!
There was a problem hiding this comment.
One important thing to mention is thread-safety. Typically, we do not update the environment after the creation and any thread or even multiple sessions can use it.
There was a problem hiding this comment.
One important thing to mention is thread-safety. Typically, we do not update the environment after the creation and any thread or even multiple sessions can use it.
Really appreciate the context you shared. The reason adding this env_update feature is this feature exists in Pybind but missing in c# binding, and we would like to unify the user experience and provide the ability to adjust default logger
This feature reuses the existing design in Pybind:set_default_logger_severity. Do you have any suggestions in order to improve this design?
There was a problem hiding this comment.
I understand. One thing to note, we usually pass the object ptr as a first argument, as you can see in other examples. Please, adjust.
| public IntPtr ReleaseKernelInfo; | ||
|
|
||
| public IntPtr GetTrainingApi; | ||
| public IntPtr SessionOptionsAppendExecutionProvider_CANN; |
There was a problem hiding this comment.
Are these CANN related declarations expected to be here?
| public LogLevel GetLogLevel() | ||
| { | ||
| return currentLogLevel; | ||
| } |
There was a problem hiding this comment.
If this is really needed, it should be a property. And you can then combine set/get #Resolved
There was a problem hiding this comment.
Thanks for sharing! This has been improved in the latest commit and verified in test case.
| API_IMPL_BEGIN | ||
| LoggingManager* default_logging_manager = ort_env->GetLoggingManager(); | ||
| int severity_level = static_cast<int>(log_severity_level); | ||
| default_logging_manager->SetDefaultLoggerSeverity(static_cast<logging::Severity>(severity_level)); |
### Description * Add getter/setter to access and update C# OrtEnv log level * Add C API about updating ort env with custom log level to support the setter above (Following [pybind implementation](https://github.com/microsoft/onnxruntime/blob/952c99304a764328070ac6c07f510deec06dedf4/onnxruntime/python/onnxruntime_pybind_state.cc#L923-L924)) * Add test case to verify getter & setter ### Motivation and Context * For C++/Python, the log level can be adjusted via OrtEnv, and this feature is missing in C# binding
Description
Motivation and Context