Home | History | Annotate | Download | only in patch
      1 diff --git a/base/logging.cc b/base/logging.cc
      2 index 8eabda0..112afb8 100644
      3 --- a/base/logging.cc
      4 +++ b/base/logging.cc
      5 @@ -58,7 +58,7 @@ typedef HANDLE MutexHandle;
      6  #include <zircon/syscalls.h>
      7  #endif
      8  
      9 -#if defined(OS_ANDROID)
     10 +#if defined(OS_ANDROID) || defined(__ANDROID__)
     11  #include <android/log.h>
     12  #endif
     13  
     14 @@ -407,21 +407,23 @@ bool BaseInitLoggingImpl(const LoggingSettings& settings) {
     15    // Can log only to the system debug log.
     16    CHECK_EQ(settings.logging_dest & ~LOG_TO_SYSTEM_DEBUG_LOG, 0);
     17  #endif
     18 -  base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
     19 -  // Don't bother initializing |g_vlog_info| unless we use one of the
     20 -  // vlog switches.
     21 -  if (command_line->HasSwitch(switches::kV) ||
     22 -      command_line->HasSwitch(switches::kVModule)) {
     23 -    // NOTE: If |g_vlog_info| has already been initialized, it might be in use
     24 -    // by another thread. Don't delete the old VLogInfo, just create a second
     25 -    // one. We keep track of both to avoid memory leak warnings.
     26 -    CHECK(!g_vlog_info_prev);
     27 -    g_vlog_info_prev = g_vlog_info;
     28 -
     29 -    g_vlog_info =
     30 -        new VlogInfo(command_line->GetSwitchValueASCII(switches::kV),
     31 -                     command_line->GetSwitchValueASCII(switches::kVModule),
     32 -                     &g_min_log_level);
     33 +  if (base::CommandLine::InitializedForCurrentProcess()) {
     34 +    base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
     35 +    // Don't bother initializing |g_vlog_info| unless we use one of the
     36 +    // vlog switches.
     37 +    if (command_line->HasSwitch(switches::kV) ||
     38 +        command_line->HasSwitch(switches::kVModule)) {
     39 +      // NOTE: If |g_vlog_info| has already been initialized, it might be in use
     40 +      // by another thread. Don't delete the old VLogInfo, just create a second
     41 +      // one. We keep track of both to avoid memory leak warnings.
     42 +      CHECK(!g_vlog_info_prev);
     43 +      g_vlog_info_prev = g_vlog_info;
     44 +
     45 +      g_vlog_info =
     46 +          new VlogInfo(command_line->GetSwitchValueASCII(switches::kV),
     47 +                       command_line->GetSwitchValueASCII(switches::kVModule),
     48 +                       &g_min_log_level);
     49 +    }
     50    }
     51  
     52    g_logging_destination = settings.logging_dest;
     53 @@ -755,7 +757,7 @@ LogMessage::~LogMessage() {
     54                         str_newline.c_str());
     55  #endif  // defined(USE_ASL)
     56      }
     57 -#elif defined(OS_ANDROID)
     58 +#elif defined(OS_ANDROID) || defined(__ANDROID__)
     59      android_LogPriority priority =
     60          (severity_ < 0) ? ANDROID_LOG_VERBOSE : ANDROID_LOG_UNKNOWN;
     61      switch (severity_) {
     62 @@ -772,7 +774,16 @@ LogMessage::~LogMessage() {
     63          priority = ANDROID_LOG_FATAL;
     64          break;
     65      }
     66 +#if defined(OS_ANDROID)
     67      __android_log_write(priority, "chromium", str_newline.c_str());
     68 +#else
     69 +    __android_log_write(
     70 +        priority,
     71 +        base::CommandLine::InitializedForCurrentProcess() ?
     72 +            base::CommandLine::ForCurrentProcess()->
     73 +                GetProgram().BaseName().value().c_str() : nullptr,
     74 +        str_newline.c_str());
     75 +#endif  // defined(OS_ANDROID)
     76  #endif
     77      ignore_result(fwrite(str_newline.data(), str_newline.size(), 1, stderr));
     78      fflush(stderr);
     79