Commits


Adrian Lizarraga authored and GitHub committed e42f7487dfe
Add logging APIs for custom operators (#14416) ### Description Add logging APIs for custom ops. This PR introduces a `OrtLogger` type, which can be retrieved from a `OrtKernelInfo` or `OrtKernelContext`. The kernel info's logger is the session logger stored in the execution provider. The kernel context's logger is a run logger. ### Motivation and Context Allows custom ops to log information in a manner consistent with built-in ops. Example usage in custom op: ```C++ struct MyCustomKernel { MyCustomKernel(const OrtApi& api, const OrtKernelInfo* info) { Ort::ConstKernelInfo kinfo(info); this->logger_ = kinfo.GetLogger(); // ... ORT_CXX_LOGF_NOEXCEPT(this->logger_, OrtLoggingLevel::ORT_LOGGING_LEVEL_ERROR, "Error: %s", err_msg); } void Compute(OrtKernelContext* context) { ORT_CXX_LOG(this->logger_, OrtLoggingLevel::ORT_LOGGING_LEVEL_VERBOSE, "Calling compute..."); // ... } // ... private: Ort::Logger logger_; }; ```