HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ort::Logger Struct Reference

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
 
Loggeroperator= (const Logger &)=default
 
 Logger (Logger &&v) noexcept=default
 
Loggeroperator= (Logger &&v) noexcept=default
 
OrtLoggingLevel GetLoggingSeverityLevel () const noexcept
 
Status LogMessage (OrtLoggingLevel log_severity_level, const ORTCHAR_T *file_path, int line_number, const char *func_name, const char *message) const noexcept
 
template<typename... Args>
Status LogFormattedMessage (OrtLoggingLevel log_severity_level, const ORTCHAR_T *file_path, int line_number, const char *func_name, const char *format, Args &&...args) const noexcept
 

Detailed Description

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.

Definition at line 1973 of file onnxruntime_cxx_api.h.

Constructor & Destructor Documentation

Ort::Logger::Logger ( )
default

Creates an empty Ort::Logger. Must be initialized from a valid Ort::Logger before use.

Ort::Logger::Logger ( std::nullptr_t  )
inlineexplicit

Creates an empty Ort::Logger. Must be initialized from a valid Ort::Logger before use.

Definition at line 1982 of file onnxruntime_cxx_api.h.

Ort::Logger::Logger ( const OrtLogger *  logger)
inlineexplicit

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.

Parameters
loggerThe ::OrtLogger to wrap.

Definition at line 1564 of file onnxruntime_cxx_inline.h.

Ort::Logger::~Logger ( )
default
Ort::Logger::Logger ( const Logger )
default
Ort::Logger::Logger ( Logger &&  v)
defaultnoexcept

Member Function Documentation

OrtLoggingLevel Ort::Logger::GetLoggingSeverityLevel ( ) const
inlinenoexcept

Returns the logger's current severity level from the cached member.

Returns
The current ::OrtLoggingLevel.

Definition at line 1568 of file onnxruntime_cxx_inline.h.

template<typename... Args>
Status Ort::Logger::LogFormattedMessage ( OrtLoggingLevel  log_severity_level,
const ORTCHAR_T *  file_path,
int  line_number,
const char *  func_name,
const char *  format,
Args &&...  args 
) const
inlinenoexcept

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.

Parameters
log_severity_levelThe message's logging severity level.
file_pathThe filepath of the file in which the message is logged. Usually the value of ORT_FILE.
line_numberThe file line number in which the message is logged. Usually the value of LINE.
func_nameThe name of the function in which the message is logged. Usually the value of FUNCTION.
formatA 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.
argsZero or more variadic arguments referenced by the format string.
Returns
A Ort::Status value to indicate error or success.

Definition at line 1592 of file onnxruntime_cxx_inline.h.

Status Ort::Logger::LogMessage ( OrtLoggingLevel  log_severity_level,
const ORTCHAR_T *  file_path,
int  line_number,
const char *  func_name,
const char *  message 
) const
inlinenoexcept

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.

Parameters
log_severity_levelThe message's logging severity level.
file_pathThe filepath of the file in which the message is logged. Usually the value of ORT_FILE.
line_numberThe file line number in which the message is logged. Usually the value of LINE.
func_nameThe name of the function in which the message is logged. Usually the value of FUNCTION.
messageThe message to log.
Returns
A Ort::Status value to indicate error or success.

Definition at line 1572 of file onnxruntime_cxx_inline.h.

Logger& Ort::Logger::operator= ( const Logger )
default
Logger& Ort::Logger::operator= ( Logger &&  v)
defaultnoexcept

The documentation for this struct was generated from the following files: