ONNX Runtime
|
This class represents an ONNX Runtime logger that can be used to log information with an associated severity level and source code location (file path, line number, function name). More...
#include <onnxruntime_cxx_api.h>
Public Member Functions | |
Logger ()=default | |
Logger (std::nullptr_t) | |
Logger (const OrtLogger *logger) | |
~Logger ()=default | |
Logger (const Logger &)=default | |
Logger & | operator= (const Logger &)=default |
Logger (Logger &&v) noexcept=default | |
Logger & | operator= (Logger &&v) noexcept=default |
OrtLoggingLevel | GetLoggingSeverityLevel () const noexcept |
Status | LogMessage (OrtLoggingLevel log_severity_level, const char *file_path, int line_number, const char *func_name, const char *message) const noexcept |
template<typename... Args> | |
Status | LogFormattedMessage (OrtLoggingLevel log_severity_level, const char *file_path, int line_number, const char *func_name, const char *format, Args &&... args) const noexcept |
This class represents an ONNX Runtime logger that can be used to log information with an associated severity level and source code location (file path, line number, function name).
A Logger can be obtained from within custom operators by calling Ort::KernelInfo::GetLogger(). Instances of Ort::Logger are the size of two pointers and can be passed by value.
Use the ORT_CXX_LOG macros to ensure the source code location is set properly from the callsite and to take advantage of a cached logging severity level that can bypass calls to the underlying C API.
|
default |
Creates an empty Ort::Logger. Must be initialized from a valid Ort::Logger before use.
|
inlineexplicit |
Creates an empty Ort::Logger. Must be initialized from a valid Ort::Logger before use.
|
explicit |
Creates a logger from an OrtLogger instance. Caches the logger's current severity level by calling OrtApi::Logger_GetLoggingSeverityLevel. Throws an exception if OrtApi::Logger_GetLoggingSeverityLevel fails.
logger | The OrtLogger to wrap. |
|
default |
|
default |
|
defaultnoexcept |
|
noexcept |
Returns the logger's current severity level from the cached member.
|
noexcept |
Logs a printf-like formatted message via OrtApi::Logger_LogMessage. Use the ORT_CXX_LOGF or ORT_CXX_LOGF_NOEXCEPT macros to properly set the source code location and to use the cached severity level to potentially bypass calls to the underlying C API. Returns an error status if a formatting error occurs.
log_severity_level | The message's logging severity level. |
file_path | The filepath of the file in which the message is logged. Usually the value of ORT_FILE. |
line_number | The file line number in which the message is logged. Usually the value of LINE. |
func_name | The name of the function in which the message is logged. Usually the value of FUNCTION. |
format | A null-terminated UTF-8 format string forwarded to a printf-like function. Refer to https://en.cppreference.com/w/cpp/io/c/fprintf for information on valid formats. |
args | Zero or more variadic arguments referenced by the format string. |
|
noexcept |
Logs the provided message via OrtApi::Logger_LogMessage. Use the ORT_CXX_LOG or ORT_CXX_LOG_NOEXCEPT macros to properly set the source code location and to use the cached severity level to potentially bypass calls to the underlying C API.
log_severity_level | The message's logging severity level. |
file_path | The filepath of the file in which the message is logged. Usually the value of ORT_FILE. |
line_number | The file line number in which the message is logged. Usually the value of LINE. |
func_name | The name of the function in which the message is logged. Usually the value of FUNCTION. |
message | The message to log. |