Skip to content

Commit

Permalink
adding json logging macros
Browse files Browse the repository at this point in the history
  • Loading branch information
nnshah1 committed May 14, 2024
1 parent 9dfb76b commit 47fd5ee
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions include/triton/backend/backend_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,29 @@ namespace triton { namespace backend {
("failed to log message: ")); \
} while (false)

#define LOG_JSON_MESSAGE(LEVEL, PREAMBLE, MSG) \
do { \
LOG_IF_ERROR( \
TRITONSERVER_LogJsonMessage(LEVEL, __FILE__, __LINE__, PREAMBLE, MSG), \
("failed to log JSON message: ")); \
} while (false)

#define LOG_JSON_VALUE(LEVEL, PREAMBLE, VALUE) \
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_LogJsonMessage( \
TRITONSERVER_LOG_INFO, __FILE__, __LINE__, PREAMBLE, message), \
(error_message)); \
LOG_IF_ERROR(TRITONSERVER_MessageDelete(message), (error_message)); \
} while (false)

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

0 comments on commit 47fd5ee

Please sign in to comment.