diff --git a/include/triton/backend/backend_common.h b/include/triton/backend/backend_common.h index 84c889e..4d27771 100644 --- a/include/triton/backend/backend_common.h +++ b/include/triton/backend/backend_common.h @@ -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) \ + 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 { \