Add log callback support to Logger class#149
Open
nbarbier-amira wants to merge 1 commit intotriton-inference-server:mainfrom
Open
Add log callback support to Logger class#149nbarbier-amira wants to merge 1 commit intotriton-inference-server:mainfrom
nbarbier-amira wants to merge 1 commit intotriton-inference-server:mainfrom
Conversation
This adds the ability to register a callback function that receives log messages, enabling integration with external logging systems. Features: - New LogCallbackFn typedef for the callback function signature - SetLogCallback() method to register/unregister callbacks - Callbacks receive log level, source filename, line number, and message - Option to replace default logging or use callback in addition to it - LOG_SET_CALLBACK macro for convenient access The callback is invoked from the Log() method before (or instead of) writing to stdout/stderr/file, depending on the replace_default_logger setting. Resolves triton-inference-server/server#8304
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds callback-based logging to the Logger class, which allows applications embedding Triton to hook into the logging system and forward messages to their own logging infrastructure.
Motivation
Currently the only way to capture Triton logs programmatically is to redirect to a file and parse it. This is awkward for applications that want to integrate Triton logs with their existing logging setup (structured logging, log aggregation services, etc). See triton-inference-server/server#8304.
Changes
LogCallbackFntypedef andSetLogCallback()method on LoggerLOG_SET_CALLBACKmacro follows existing patternExample
Notes
This is the foundation for adding
TRITONSERVER_ServerOptionsSetLogCallbackto the C API in triton-core (separate PR).Backward compatible - default behavior unchanged when no callback is registered.