Skip to content

Commit 2a19535

Browse files
authored
DPL: allow closing a signpost interval with an error (#14692)
The error will be printed regardless of the signposts being enabled. In case the signposts are actually enabled, the error will be the closing message of the signpost interval. In case the signposts are not enabled, the error will be printed as a standard error.
1 parent cec632f commit 2a19535

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Framework/Foundation/include/Framework/Signpost.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,16 @@ void o2_debug_log_set_stacktrace(_o2_log_t* log, int stacktrace)
611611
} else if (O2_BUILTIN_UNLIKELY(private_o2_log_##log->stacktrace)) { \
612612
_o2_signpost_interval_end(private_o2_log_##log, id, name, remove_engineering_type(format).data(), ##__VA_ARGS__); \
613613
}
614+
// Print out a message at error level in any case even if the signpost is not enable.
615+
// If it is enabled, behaves like O2_SIGNPOST_END.
616+
#define O2_SIGNPOST_END_WITH_ERROR(log, id, name, format, ...) \
617+
if (O2_BUILTIN_UNLIKELY(O2_SIGNPOST_ENABLED_MAC(log))) { \
618+
O2_SIGNPOST_END_MAC(log, id, name, format, ##__VA_ARGS__); \
619+
} else if (O2_BUILTIN_UNLIKELY(private_o2_log_##log->stacktrace)) { \
620+
_o2_signpost_interval_end(private_o2_log_##log, id, name, remove_engineering_type(format).data(), ##__VA_ARGS__); \
621+
} else { \
622+
O2_LOG_MACRO_RAW(error, remove_engineering_type(format).data(), ##__VA_ARGS__); \
623+
}
614624
#else // This is the release implementation, it does nothing.
615625
#define O2_DECLARE_DYNAMIC_LOG(x)
616626
#define O2_DECLARE_DYNAMIC_STACKTRACE_LOG(x)

0 commit comments

Comments
 (0)