Skip to content
Merged
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
18 changes: 12 additions & 6 deletions Framework/Foundation/include/Framework/Signpost.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ inline _o2_signpost_id_t _o2_signpost_id_make_with_pointer(_o2_log_t* log, void
#include <execinfo.h>
#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
Expand Down Expand Up @@ -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;

Expand All @@ -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];
Expand All @@ -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, ...)
Expand Down Expand Up @@ -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
Expand Down