| Index: chrome/common/logging_chrome.cc
|
| diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc
|
| index 4e2df8c8efdf47d8b3ab16953696495eaf4d7c70..8f676714335e5ad2481bdccc82fea7ac4eca6048 100644
|
| --- a/chrome/common/logging_chrome.cc
|
| +++ b/chrome/common/logging_chrome.cc
|
| @@ -47,7 +47,6 @@
|
| #include "base/strings/string_util.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| -#include "base/threading/thread_restrictions.h"
|
| #include "chrome/common/chrome_constants.h"
|
| #include "chrome/common/chrome_paths.h"
|
| #include "chrome/common/chrome_switches.h"
|
| @@ -66,11 +65,12 @@
|
| #include "chrome/install_static/install_details.h"
|
| #endif
|
|
|
| +namespace logging {
|
| namespace {
|
|
|
| // When true, this means that error dialogs should not be shown.
|
| bool dialogs_are_suppressed_ = false;
|
| -logging::ScopedLogAssertHandler* assert_handler_ = nullptr;
|
| +ScopedLogAssertHandler* assert_handler_ = nullptr;
|
|
|
| // This should be true for exactly the period between the end of
|
| // InitChromeLogging() and the beginning of CleanupChromeLogging().
|
| @@ -108,8 +108,8 @@ void SuppressDialogs() {
|
| if (dialogs_are_suppressed_)
|
| return;
|
|
|
| - assert_handler_ = new logging::ScopedLogAssertHandler(
|
| - base::Bind(SilentRuntimeAssertHandler));
|
| + assert_handler_ =
|
| + new ScopedLogAssertHandler(base::Bind(SilentRuntimeAssertHandler));
|
|
|
| #if defined(OS_WIN)
|
| UINT new_flags = SEM_FAILCRITICALERRORS |
|
| @@ -126,39 +126,37 @@ void SuppressDialogs() {
|
|
|
| } // anonymous namespace
|
|
|
| -namespace logging {
|
| -
|
| -LoggingDestination DetermineLogMode(const base::CommandLine& command_line) {
|
| - // only use OutputDebugString in debug mode
|
| +LoggingDestination DetermineLoggingDestination(
|
| + const base::CommandLine& command_line) {
|
| +// only use OutputDebugString in debug mode
|
| #ifdef NDEBUG
|
| bool enable_logging = false;
|
| const char *kInvertLoggingSwitch = switches::kEnableLogging;
|
| - const logging::LoggingDestination kDefaultLoggingMode = logging::LOG_TO_FILE;
|
| + const LoggingDestination kDefaultLoggingMode = LOG_TO_FILE;
|
| #else
|
| bool enable_logging = true;
|
| const char *kInvertLoggingSwitch = switches::kDisableLogging;
|
| - const logging::LoggingDestination kDefaultLoggingMode = logging::LOG_TO_ALL;
|
| + const LoggingDestination kDefaultLoggingMode = LOG_TO_ALL;
|
| #endif
|
|
|
| if (command_line.HasSwitch(kInvertLoggingSwitch))
|
| enable_logging = !enable_logging;
|
|
|
| - logging::LoggingDestination log_mode;
|
| + LoggingDestination log_mode;
|
| if (enable_logging) {
|
| // Let --enable-logging=stderr force only stderr, particularly useful for
|
| // non-debug builds where otherwise you can't get logs to stderr at all.
|
| if (command_line.GetSwitchValueASCII(switches::kEnableLogging) == "stderr")
|
| - log_mode = logging::LOG_TO_SYSTEM_DEBUG_LOG;
|
| + log_mode = LOG_TO_SYSTEM_DEBUG_LOG;
|
| else
|
| log_mode = kDefaultLoggingMode;
|
| } else {
|
| - log_mode = logging::LOG_NONE;
|
| + log_mode = LOG_NONE;
|
| }
|
| return log_mode;
|
| }
|
|
|
| #if defined(OS_CHROMEOS)
|
| -namespace {
|
| base::FilePath SetUpSymlinkIfNeeded(const base::FilePath& symlink_path,
|
| bool new_log) {
|
| DCHECK(!symlink_path.empty());
|
| @@ -196,8 +194,6 @@ void RemoveSymlinkAndLog(const base::FilePath& link_path,
|
| DPLOG(WARNING) << "Unable to unlink log file " << target_path.value();
|
| }
|
|
|
| -} // anonymous namespace
|
| -
|
| base::FilePath GetSessionLogDir(const base::CommandLine& command_line) {
|
| base::FilePath log_dir;
|
| std::string log_dir_str;
|
| @@ -228,39 +224,6 @@ base::FilePath GetSessionLogFile(const base::CommandLine& command_line) {
|
| return GetSessionLogDir(command_line).Append(GetLogFileName().BaseName());
|
| }
|
|
|
| -void RedirectChromeLogging(const base::CommandLine& command_line) {
|
| - if (chrome_logging_redirected_) {
|
| - // TODO(nkostylev): Support multiple active users. http://crbug.com/230345
|
| - LOG(WARNING) << "NOT redirecting logging for multi-profiles case.";
|
| - return;
|
| - }
|
| -
|
| - DCHECK(!chrome_logging_redirected_) <<
|
| - "Attempted to redirect logging when it was already initialized.";
|
| -
|
| - // Redirect logs to the session log directory, if set. Otherwise
|
| - // defaults to the profile dir.
|
| - base::FilePath log_path = GetSessionLogFile(command_line);
|
| -
|
| - // Creating symlink causes us to do blocking IO on UI thread.
|
| - // Temporarily allow it until we fix http://crbug.com/61143
|
| - base::ThreadRestrictions::ScopedAllowIO allow_io;
|
| - // Always force a new symlink when redirecting.
|
| - base::FilePath target_path = SetUpSymlinkIfNeeded(log_path, true);
|
| -
|
| - // ChromeOS always logs through the symlink, so it shouldn't be
|
| - // deleted if it already exists.
|
| - logging::LoggingSettings settings;
|
| - settings.logging_dest = DetermineLogMode(command_line);
|
| - settings.log_file = log_path.value().c_str();
|
| - if (!logging::InitLogging(settings)) {
|
| - DLOG(ERROR) << "Unable to initialize logging to " << log_path.value();
|
| - RemoveSymlinkAndLog(log_path, target_path);
|
| - } else {
|
| - chrome_logging_redirected_ = true;
|
| - }
|
| -}
|
| -
|
| #endif // OS_CHROMEOS
|
|
|
| void InitChromeLogging(const base::CommandLine& command_line,
|
| @@ -268,7 +231,7 @@ void InitChromeLogging(const base::CommandLine& command_line,
|
| DCHECK(!chrome_logging_initialized_) <<
|
| "Attempted to initialize logging when it was already initialized.";
|
|
|
| - LoggingDestination logging_dest = DetermineLogMode(command_line);
|
| + LoggingDestination logging_dest = DetermineLoggingDestination(command_line);
|
| LogLockingState log_locking_state = LOCK_LOG_FILE;
|
| base::FilePath log_path;
|
| #if defined(OS_CHROMEOS)
|
| @@ -291,23 +254,23 @@ void InitChromeLogging(const base::CommandLine& command_line,
|
| // symlink if we've been asked to delete the old log, since that
|
| // indicates the start of a new session.
|
| target_path = SetUpSymlinkIfNeeded(
|
| - log_path, delete_old_log_file == logging::DELETE_OLD_LOG_FILE);
|
| + log_path, delete_old_log_file == DELETE_OLD_LOG_FILE);
|
|
|
| // Because ChromeOS manages the move to a new session by redirecting
|
| // the link, it shouldn't remove the old file in the logging code,
|
| // since that will remove the newly created link instead.
|
| - delete_old_log_file = logging::APPEND_TO_OLD_LOG_FILE;
|
| + delete_old_log_file = APPEND_TO_OLD_LOG_FILE;
|
| #endif
|
| } else {
|
| log_locking_state = DONT_LOCK_LOG_FILE;
|
| }
|
|
|
| - logging::LoggingSettings settings;
|
| + LoggingSettings settings;
|
| settings.logging_dest = logging_dest;
|
| settings.log_file = log_path.value().c_str();
|
| settings.lock_log = log_locking_state;
|
| settings.delete_old = delete_old_log_file;
|
| - bool success = logging::InitLogging(settings);
|
| + bool success = InitLogging(settings);
|
|
|
| #if defined(OS_CHROMEOS)
|
| if (!success) {
|
| @@ -328,13 +291,13 @@ void InitChromeLogging(const base::CommandLine& command_line,
|
| // Default to showing error dialogs.
|
| if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| switches::kNoErrorDialogs))
|
| - logging::SetShowErrorDialogs(true);
|
| + SetShowErrorDialogs(true);
|
|
|
| // we want process and thread IDs because we have a lot of things running
|
| - logging::SetLogItems(true, // enable_process_id
|
| - true, // enable_thread_id
|
| - true, // enable_timestamp
|
| - false); // enable_tickcount
|
| + SetLogItems(true, // enable_process_id
|
| + true, // enable_thread_id
|
| + true, // enable_timestamp
|
| + false); // enable_tickcount
|
|
|
| // We call running in unattended mode "headless", and allow
|
| // headless mode to be configured either by the Environment
|
| @@ -348,17 +311,17 @@ void InitChromeLogging(const base::CommandLine& command_line,
|
| // Use a minimum log level if the command line asks for one. Ignore this
|
| // switch if there's vlog level switch present too (as both of these switches
|
| // refer to the same underlying log level, and the vlog level switch has
|
| - // already been processed inside logging::InitLogging). If there is neither
|
| + // already been processed inside InitLogging). If there is neither
|
| // log level nor vlog level specified, then just leave the default level
|
| // (INFO).
|
| if (command_line.HasSwitch(switches::kLoggingLevel) &&
|
| - logging::GetMinLogLevel() >= 0) {
|
| + GetMinLogLevel() >= 0) {
|
| std::string log_level =
|
| command_line.GetSwitchValueASCII(switches::kLoggingLevel);
|
| int level = 0;
|
| if (base::StringToInt(log_level, &level) && level >= 0 &&
|
| level < LOG_NUM_SEVERITIES) {
|
| - logging::SetMinLogLevel(level);
|
| + SetMinLogLevel(level);
|
| } else {
|
| DLOG(WARNING) << "Bad log level: " << log_level;
|
| }
|
| @@ -366,10 +329,10 @@ void InitChromeLogging(const base::CommandLine& command_line,
|
|
|
| #if defined(OS_WIN)
|
| // Enable trace control and transport through event tracing for Windows.
|
| - logging::LogEventProvider::Initialize(kChromeTraceProviderName);
|
| + LogEventProvider::Initialize(kChromeTraceProviderName);
|
|
|
| // Enable logging to the Windows Event Log.
|
| - logging::SetEventSourceName(base::UTF16ToASCII(
|
| + SetEventSourceName(base::UTF16ToASCII(
|
| install_static::InstallDetails::Get().install_full_name()));
|
| #endif
|
|
|
|
|