diff --git a/Framework/Foundation/include/Framework/Signpost.h b/Framework/Foundation/include/Framework/Signpost.h index 0ea0a1f5ec75b..7ed544c529303 100644 --- a/Framework/Foundation/include/Framework/Signpost.h +++ b/Framework/Foundation/include/Framework/Signpost.h @@ -246,6 +246,7 @@ inline _o2_signpost_id_t _o2_signpost_id_make_with_pointer(_o2_log_t* log, void #include #include "Framework/RuntimeError.h" #include "Framework/BacktraceHelpers.h" +void _o2_signpost_event_emit_v(_o2_log_t* log, _o2_signpost_id_t id, char const* name, char const* const format, va_list args); void _o2_signpost_interval_end_v(_o2_log_t* log, _o2_signpost_id_t id, char const* name, char const* const format, va_list args); // returns true if the push was successful, false if the stack was full @@ -358,11 +359,8 @@ void* _o2_log_create(char const* name, int defaultStacktrace) // This will look at the slot in the log associated to the ID. // If the slot is empty, it will return the id and increment the indentation level. -void _o2_signpost_event_emit(_o2_log_t* log, _o2_signpost_id_t id, char const* name, char const* const format, ...) +void _o2_signpost_event_emit_v(_o2_log_t* log, _o2_signpost_id_t id, char const* name, char const* const format, va_list args) { - va_list args; - va_start(args, format); - // Find the index of the activity int leading = 0; @@ -386,7 +384,6 @@ void _o2_signpost_event_emit(_o2_log_t* log, _o2_signpost_id_t id, char const* n char prebuffer[4096]; int s = snprintf(prebuffer, 4096, "id%.16" PRIx64 ":%-16s*>%*c", id.value, name, leading, ' '); vsnprintf(prebuffer + s, 4096 - s, format, args); - va_end(args); O2_LOG_MACRO("%s", prebuffer); if (log->stacktrace > 1) { void* traces[o2::framework::BacktraceHelpers::MAX_BACKTRACE_SIZE]; @@ -396,6 +393,15 @@ void _o2_signpost_event_emit(_o2_log_t* log, _o2_signpost_id_t id, char const* n } } +// We separate this so that we can still emit the end signpost when the log is not enabled. +void _o2_signpost_event_emit(_o2_log_t* log, _o2_signpost_id_t id, char const* name, char const* const format, ...) +{ + va_list args; + va_start(args, format); + _o2_signpost_event_emit_v(log, id, name, format, args); + va_end(args); +} + // This will look at the slot in the log associated to the ID. // If the slot is empty, it will return the id and increment the indentation level. void _o2_signpost_interval_begin(_o2_log_t* log, _o2_signpost_id_t id, char const* name, char const* const format, ...) @@ -434,7 +440,7 @@ void _o2_signpost_interval_end_v(_o2_log_t* log, _o2_signpost_id_t id, char cons // We should not make this an error because one could have enabled the log after the interval // was started. if (i == log->ids.size()) { - _o2_signpost_event_emit(log, id, name, format, args); + _o2_signpost_event_emit_v(log, id, name, format, args); return; } // i is the slot index