Commit 9873826d authored by Kevin Marshall's avatar Kevin Marshall Committed by Commit Bot

[Fuchsia] Remove redundant Chromium log data from Fuchsia syslog.

Chromium's log output to the Fuchsia logging service has a lot of
header boilerplate because each log line has concatenated prefixes
from both Chromium and Fuchsia. This makes syslog data hard to read
because each line is very likely to wrap around on an 80-100col
terminal.

This CL strips the Chromium logging prefix from the logging data
and provides log lines' source location as log "tags".

Sample log line prefix, before this CL (146 chars):
[00582.348425][130450][130452][ui_base_unittests__exec] ERROR: \
[130450:3944750047:1007/220315.685215:582348409:ERROR:base_paths_fuchsia.cc(21)] ...

Sample log line prefix, after this CL (89 chars):
[00517.527091][108865][108867][ui_base_unittests__exec] ERROR: base_paths_fuchsia.cc(21) ...

Bug: 1012037
Change-Id: Ia51442711ca8575246170b5090a4abafc45fcc43
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1846395
Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Auto-Submit: Kevin Marshall <kmarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705656}
parent 5a1b69b8
...@@ -858,9 +858,13 @@ LogMessage::~LogMessage() { ...@@ -858,9 +858,13 @@ LogMessage::~LogMessage() {
fx_logger_t* logger = fx_log_get_logger(); fx_logger_t* logger = fx_log_get_logger();
if (logger) { if (logger) {
// Temporarily pop the trailing newline, since fx_logger will add one. // Temporarily remove the trailing newline from |str_newline|'s C-string
// representation, since fx_logger will add a newline of its own.
str_newline.pop_back(); str_newline.pop_back();
fx_logger_log(logger, severity, nullptr, str_newline.c_str()); std::string message =
base::StringPrintf("%s(%d) %s", file_basename_, line_,
str_newline.c_str() + message_start_);
fx_logger_log(logger, severity, nullptr, message.data());
str_newline.push_back('\n'); str_newline.push_back('\n');
} }
#endif // OS_FUCHSIA #endif // OS_FUCHSIA
...@@ -962,6 +966,9 @@ void LogMessage::Init(const char* file, int line) { ...@@ -962,6 +966,9 @@ void LogMessage::Init(const char* file, int line) {
if (last_slash_pos != base::StringPiece::npos) if (last_slash_pos != base::StringPiece::npos)
filename.remove_prefix(last_slash_pos + 1); filename.remove_prefix(last_slash_pos + 1);
// Stores the base name as the null-terminated suffix substring of |filename|.
file_basename_ = filename.data();
// TODO(darin): It might be nice if the columns were fixed width. // TODO(darin): It might be nice if the columns were fixed width.
stream_ << '['; stream_ << '[';
......
...@@ -921,6 +921,7 @@ class BASE_EXPORT LogMessage { ...@@ -921,6 +921,7 @@ class BASE_EXPORT LogMessage {
// The file and line information passed in to the constructor. // The file and line information passed in to the constructor.
const char* file_; const char* file_;
const int line_; const int line_;
const char* file_basename_;
// This is useful since the LogMessage class uses a lot of Win32 calls // This is useful since the LogMessage class uses a lot of Win32 calls
// that will lose the value of GLE and the code that called the log function // that will lose the value of GLE and the code that called the log function
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment