From cb876a0b3ba08d40d2add3d8fca849b5a2b6470f Mon Sep 17 00:00:00 2001 From: Jelle Foks Date: Thu, 3 Aug 2023 14:28:05 -0700 Subject: [PATCH] Add Cobalt console messages to trace. This adds LogMessage trace events for the Cobalt log messsages, similar to Chrome. b/251825168 --- base/logging.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/base/logging.cc b/base/logging.cc index 768889c1bba7..772cccde55b6 100644 --- a/base/logging.cc +++ b/base/logging.cc @@ -7,6 +7,7 @@ #include #include "base/macros.h" +#include "base/trace_event/trace_event.h" #include "build/build_config.h" #if defined(STARBOARD) @@ -485,6 +486,12 @@ SbLogPriority LogLevelToStarboardLogPriority(int level) { } #endif // defined(STARBOARD) +// Invokes macro to record trace event when a log message is emitted. +void TraceLogMessage(const char* file, int line, const std::string& message) { + TRACE_EVENT_INSTANT1("log", "LogMessage", TRACE_EVENT_SCOPE_THREAD, "message", + message); +} + } // namespace #if DCHECK_IS_CONFIGURABLE @@ -723,6 +730,7 @@ LogMessage::~LogMessage() { #endif stream_ << std::endl; std::string str_newline(stream_.str()); + TraceLogMessage(file_, line_, str_newline); // Give any log message handler first dibs on the message. if (log_message_handler &&