Skip to content

Commit

Permalink
Add Cobalt console messages to trace.
Browse files Browse the repository at this point in the history
This adds LogMessage trace events for the Cobalt log messsages, similar to
Chrome.

b/251825168
  • Loading branch information
jellefoks committed Aug 3, 2023
1 parent 7f8a3b6 commit cb876a0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions base/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <limits.h>

#include "base/macros.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"

#if defined(STARBOARD)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 &&
Expand Down

0 comments on commit cb876a0

Please sign in to comment.