diff --git a/Framework/Core/src/runDataProcessing.cxx b/Framework/Core/src/runDataProcessing.cxx index 933eb1dda52cf..4cec8c63fe856 100644 --- a/Framework/Core/src/runDataProcessing.cxx +++ b/Framework/Core/src/runDataProcessing.cxx @@ -2741,9 +2741,20 @@ void enableSignposts(std::string const& signpostsToEnable) auto* log = (_o2_log_t*)l; auto* selectedName = (char const*)context; std::string prefix = "ch.cern.aliceo2."; - if (strcmp(name, (prefix + selectedName).data()) == 0) { - LOGP(info, "Enabling signposts for stream \"ch.cern.aliceo2.{}\"", selectedName); - _o2_log_set_stacktrace(log, 1); + auto* last = strchr(selectedName, ':'); + int maxDepth = 1; + if (last) { + char* err; + maxDepth = strtol(last + 1, &err, 10); + if (*(last + 1) == '\0' || *err != '\0') { + maxDepth = 1; + } + } + + auto fullName = prefix + std::string{selectedName, last ? last - selectedName : strlen(selectedName)}; + if (strncmp(name, fullName.data(), fullName.size()) == 0) { + LOGP(info, "Enabling signposts for stream \"{}\" with depth {}.", fullName, maxDepth); + _o2_log_set_stacktrace(log, maxDepth); return false; } else { LOGP(info, "Signpost stream \"{}\" disabled. Enable it with o2-log -p {} -a {}", name, pid, (void*)&log->stacktrace); diff --git a/Framework/Foundation/include/Framework/Signpost.h b/Framework/Foundation/include/Framework/Signpost.h index 5e844ce01b20c..74368f73c382e 100644 --- a/Framework/Foundation/include/Framework/Signpost.h +++ b/Framework/Foundation/include/Framework/Signpost.h @@ -381,7 +381,8 @@ void _o2_signpost_event_emit(_o2_log_t* log, _o2_signpost_id_t id, char const* n O2_LOG_MACRO("%s", prebuffer); if (log->stacktrace > 1) { void* traces[o2::framework::BacktraceHelpers::MAX_BACKTRACE_SIZE]; - int maxBacktrace = backtrace(traces, o2::framework::BacktraceHelpers::MAX_BACKTRACE_SIZE); + // We add one extra frame, because one is for the logging + int maxBacktrace = backtrace(traces, (log->stacktrace + 1) < o2::framework::BacktraceHelpers::MAX_BACKTRACE_SIZE ? (log->stacktrace + 1) : o2::framework::BacktraceHelpers::MAX_BACKTRACE_SIZE); o2::framework::BacktraceHelpers::demangled_backtrace_symbols(traces, maxBacktrace, STDERR_FILENO); } }