diff options
author | Daniel Erat <derat@google.com> | 2015-09-15 08:55:55 -0600 |
---|---|---|
committer | Daniel Erat <derat@google.com> | 2015-09-15 10:34:25 -0600 |
commit | 4e3fd7a0405fe3443a22a50c28fbb32ae96acd40 (patch) | |
tree | ece07a95f565028ff0df2842cdd2ad3205880781 /base | |
parent | c1e61c51d2705905445d148721157030614694cd (diff) | |
download | libchrome-4e3fd7a0405fe3443a22a50c28fbb32ae96acd40.tar.gz |
Use program name as Android log tag.
To make it easier to attribute log messages, use argv[0]'s
basename (as supplied by base::CommandLine::GetProgram()) as
the log tag. This only affects libchrome builds for Android
(i.e. when __ANDROID__ is defined but OS_ANDROID isn't).
Bug: 23168740
Change-Id: I5a95602877c393d1e05b3ae8a31a25c7b47d3ce1
Diffstat (limited to 'base')
-rw-r--r-- | base/logging.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/base/logging.cc b/base/logging.cc index 594c222450..98d149d6e7 100644 --- a/base/logging.cc +++ b/base/logging.cc @@ -39,6 +39,7 @@ typedef pthread_mutex_t* MutexHandle; #endif #include <algorithm> +#include <cassert> #include <cstring> #include <ctime> #include <iomanip> @@ -50,6 +51,7 @@ typedef pthread_mutex_t* MutexHandle; #include "base/debug/alias.h" #include "base/debug/debugger.h" #include "base/debug/stack_trace.h" +#include "base/files/file_path.h" #include "base/posix/eintr_wrapper.h" #include "base/strings/string_piece.h" #include "base/strings/string_util.h" @@ -579,7 +581,12 @@ LogMessage::~LogMessage() { #if defined(OS_ANDROID) __android_log_write(priority, "chromium", str_newline.c_str()); #else - __android_log_write(priority, NULL, str_newline.c_str()); + assert(base::CommandLine::InitializedForCurrentProcess()); + __android_log_write( + priority, + base::CommandLine::ForCurrentProcess()-> + GetProgram().BaseName().value().c_str(), + str_newline.c_str()); #endif // defined(OS_ANDROID) #endif ignore_result(fwrite(str_newline.data(), str_newline.size(), 1, stderr)); |