Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding json logging macros #97

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions include/triton/backend/backend_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,30 @@ namespace triton { namespace backend {
("failed to log message: ")); \
} while (false)

#define LOG_SERVER_MESSAGE(LEVEL, HEADING, MSG) \
do { \
LOG_IF_ERROR( \
TRITONSERVER_LogServerMessage( \
LEVEL, __FILE__, __LINE__, HEADING, MSG), \
("failed to log message: ")); \
} while (false)

#define LOG_JSON_VALUE(LEVEL, HEADING, VALUE) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused arg LEVEL

do { \
const char* error_message = "failed to log JSON message: "; \
triton::common::TritonJson::WriteBuffer buffer; \
TRITONSERVER_Message* message; \
LOG_IF_ERROR(VALUE.PrettyWrite(&buffer), (error_message)); \
LOG_IF_ERROR( \
TRITONSERVER_MessageNewFromSerializedJson( \
&message, buffer.Contents().c_str(), buffer.Contents().length()), \
error_message); \
LOG_IF_ERROR( \
TRITONSERVER_LogServerMessage( \
TRITONSERVER_LOG_INFO, __FILE__, __LINE__, HEADING, message), \
(error_message)); \
LOG_IF_ERROR(TRITONSERVER_MessageDelete(message), (error_message)); \
} while (false)

#define RETURN_ERROR_IF_FALSE(P, C, MSG) \
do { \
Expand Down
Loading