Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 // Need to include this before most other files because it defines | 7 // Need to include this before most other files because it defines |
| 8 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define | 8 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define |
| 9 // IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the | 9 // IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the |
| 10 // ViewMsgLog et al. functions. | 10 // ViewMsgLog et al. functions. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 #include "base/debug/dump_without_crashing.h" | 40 #include "base/debug/dump_without_crashing.h" |
| 41 #include "base/environment.h" | 41 #include "base/environment.h" |
| 42 #include "base/files/file_path.h" | 42 #include "base/files/file_path.h" |
| 43 #include "base/files/file_util.h" | 43 #include "base/files/file_util.h" |
| 44 #include "base/metrics/statistics_recorder.h" | 44 #include "base/metrics/statistics_recorder.h" |
| 45 #include "base/path_service.h" | 45 #include "base/path_service.h" |
| 46 #include "base/strings/string_number_conversions.h" | 46 #include "base/strings/string_number_conversions.h" |
| 47 #include "base/strings/string_util.h" | 47 #include "base/strings/string_util.h" |
| 48 #include "base/strings/stringprintf.h" | 48 #include "base/strings/stringprintf.h" |
| 49 #include "base/strings/utf_string_conversions.h" | 49 #include "base/strings/utf_string_conversions.h" |
| 50 #include "base/threading/thread_restrictions.h" | |
| 51 #include "chrome/common/chrome_constants.h" | 50 #include "chrome/common/chrome_constants.h" |
| 52 #include "chrome/common/chrome_paths.h" | 51 #include "chrome/common/chrome_paths.h" |
| 53 #include "chrome/common/chrome_switches.h" | 52 #include "chrome/common/chrome_switches.h" |
| 54 #include "chrome/common/env_vars.h" | 53 #include "chrome/common/env_vars.h" |
| 55 #include "content/public/common/content_switches.h" | 54 #include "content/public/common/content_switches.h" |
| 56 #include "ipc/ipc_logging.h" | 55 #include "ipc/ipc_logging.h" |
| 57 | 56 |
| 58 #if defined(OS_CHROMEOS) | 57 #if defined(OS_CHROMEOS) |
| 59 #include "chromeos/chromeos_switches.h" | 58 #include "chromeos/chromeos_switches.h" |
| 60 #endif | 59 #endif |
| 61 | 60 |
| 62 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
| 63 #include <initguid.h> | 62 #include <initguid.h> |
| 64 #include "base/logging_win.h" | 63 #include "base/logging_win.h" |
| 65 #include "base/syslog_logging.h" | 64 #include "base/syslog_logging.h" |
| 66 #include "chrome/install_static/install_details.h" | 65 #include "chrome/install_static/install_details.h" |
| 67 #endif | 66 #endif |
| 68 | 67 |
| 68 namespace logging { | |
| 69 namespace { | 69 namespace { |
| 70 | 70 |
| 71 // When true, this means that error dialogs should not be shown. | 71 // When true, this means that error dialogs should not be shown. |
| 72 bool dialogs_are_suppressed_ = false; | 72 bool dialogs_are_suppressed_ = false; |
| 73 logging::ScopedLogAssertHandler* assert_handler_ = nullptr; | 73 ScopedLogAssertHandler* assert_handler_ = nullptr; |
| 74 | 74 |
| 75 // This should be true for exactly the period between the end of | 75 // This should be true for exactly the period between the end of |
| 76 // InitChromeLogging() and the beginning of CleanupChromeLogging(). | 76 // InitChromeLogging() and the beginning of CleanupChromeLogging(). |
| 77 bool chrome_logging_initialized_ = false; | 77 bool chrome_logging_initialized_ = false; |
| 78 | 78 |
| 79 // Set if we called InitChromeLogging() but failed to initialize. | 79 // Set if we called InitChromeLogging() but failed to initialize. |
| 80 bool chrome_logging_failed_ = false; | 80 bool chrome_logging_failed_ = false; |
| 81 | 81 |
| 82 // This should be true for exactly the period between the end of | 82 // This should be true for exactly the period between the end of |
| 83 // InitChromeLogging() and the beginning of CleanupChromeLogging(). | 83 // InitChromeLogging() and the beginning of CleanupChromeLogging(). |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 101 base::debug::BreakDebugger(); | 101 base::debug::BreakDebugger(); |
| 102 } | 102 } |
| 103 MSVC_ENABLE_OPTIMIZE(); | 103 MSVC_ENABLE_OPTIMIZE(); |
| 104 | 104 |
| 105 // Suppresses error/assertion dialogs and enables the logging of | 105 // Suppresses error/assertion dialogs and enables the logging of |
| 106 // those errors into silenced_errors_. | 106 // those errors into silenced_errors_. |
| 107 void SuppressDialogs() { | 107 void SuppressDialogs() { |
| 108 if (dialogs_are_suppressed_) | 108 if (dialogs_are_suppressed_) |
| 109 return; | 109 return; |
| 110 | 110 |
| 111 assert_handler_ = new logging::ScopedLogAssertHandler( | 111 assert_handler_ = |
| 112 base::Bind(SilentRuntimeAssertHandler)); | 112 new ScopedLogAssertHandler(base::Bind(SilentRuntimeAssertHandler)); |
| 113 | 113 |
| 114 #if defined(OS_WIN) | 114 #if defined(OS_WIN) |
| 115 UINT new_flags = SEM_FAILCRITICALERRORS | | 115 UINT new_flags = SEM_FAILCRITICALERRORS | |
| 116 SEM_NOGPFAULTERRORBOX | | 116 SEM_NOGPFAULTERRORBOX | |
| 117 SEM_NOOPENFILEERRORBOX; | 117 SEM_NOOPENFILEERRORBOX; |
| 118 | 118 |
| 119 // Preserve existing error mode, as discussed at http://t/dmea | 119 // Preserve existing error mode, as discussed at http://t/dmea |
| 120 UINT existing_flags = SetErrorMode(new_flags); | 120 UINT existing_flags = SetErrorMode(new_flags); |
| 121 SetErrorMode(existing_flags | new_flags); | 121 SetErrorMode(existing_flags | new_flags); |
| 122 #endif | 122 #endif |
| 123 | 123 |
| 124 dialogs_are_suppressed_ = true; | 124 dialogs_are_suppressed_ = true; |
| 125 } | 125 } |
| 126 | 126 |
| 127 } // anonymous namespace | 127 } // anonymous namespace |
| 128 | 128 |
| 129 namespace logging { | 129 LoggingDestination DetermineLoggingDestination( |
| 130 | 130 const base::CommandLine& command_line) { |
| 131 LoggingDestination DetermineLogMode(const base::CommandLine& command_line) { | 131 // only use OutputDebugString in debug mode |
|
achuithb
2017/05/25 10:06:06
git cl format seems to prefer this
| |
| 132 // only use OutputDebugString in debug mode | |
| 133 #ifdef NDEBUG | 132 #ifdef NDEBUG |
| 134 bool enable_logging = false; | 133 bool enable_logging = false; |
| 135 const char *kInvertLoggingSwitch = switches::kEnableLogging; | 134 const char *kInvertLoggingSwitch = switches::kEnableLogging; |
| 136 const logging::LoggingDestination kDefaultLoggingMode = logging::LOG_TO_FILE; | 135 const LoggingDestination kDefaultLoggingMode = LOG_TO_FILE; |
| 137 #else | 136 #else |
| 138 bool enable_logging = true; | 137 bool enable_logging = true; |
| 139 const char *kInvertLoggingSwitch = switches::kDisableLogging; | 138 const char *kInvertLoggingSwitch = switches::kDisableLogging; |
| 140 const logging::LoggingDestination kDefaultLoggingMode = logging::LOG_TO_ALL; | 139 const LoggingDestination kDefaultLoggingMode = LOG_TO_ALL; |
| 141 #endif | 140 #endif |
| 142 | 141 |
| 143 if (command_line.HasSwitch(kInvertLoggingSwitch)) | 142 if (command_line.HasSwitch(kInvertLoggingSwitch)) |
| 144 enable_logging = !enable_logging; | 143 enable_logging = !enable_logging; |
| 145 | 144 |
| 146 logging::LoggingDestination log_mode; | 145 LoggingDestination log_mode; |
| 147 if (enable_logging) { | 146 if (enable_logging) { |
| 148 // Let --enable-logging=stderr force only stderr, particularly useful for | 147 // Let --enable-logging=stderr force only stderr, particularly useful for |
| 149 // non-debug builds where otherwise you can't get logs to stderr at all. | 148 // non-debug builds where otherwise you can't get logs to stderr at all. |
| 150 if (command_line.GetSwitchValueASCII(switches::kEnableLogging) == "stderr") | 149 if (command_line.GetSwitchValueASCII(switches::kEnableLogging) == "stderr") |
| 151 log_mode = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 150 log_mode = LOG_TO_SYSTEM_DEBUG_LOG; |
| 152 else | 151 else |
| 153 log_mode = kDefaultLoggingMode; | 152 log_mode = kDefaultLoggingMode; |
| 154 } else { | 153 } else { |
| 155 log_mode = logging::LOG_NONE; | 154 log_mode = LOG_NONE; |
| 156 } | 155 } |
| 157 return log_mode; | 156 return log_mode; |
| 158 } | 157 } |
| 159 | 158 |
| 160 #if defined(OS_CHROMEOS) | 159 #if defined(OS_CHROMEOS) |
| 161 namespace { | |
| 162 base::FilePath SetUpSymlinkIfNeeded(const base::FilePath& symlink_path, | 160 base::FilePath SetUpSymlinkIfNeeded(const base::FilePath& symlink_path, |
| 163 bool new_log) { | 161 bool new_log) { |
| 164 DCHECK(!symlink_path.empty()); | 162 DCHECK(!symlink_path.empty()); |
| 165 | 163 |
| 166 // If not starting a new log, then just log through the existing | 164 // If not starting a new log, then just log through the existing |
| 167 // symlink, but if the symlink doesn't exist, create it. If | 165 // symlink, but if the symlink doesn't exist, create it. If |
| 168 // starting a new log, then delete the old symlink and make a new | 166 // starting a new log, then delete the old symlink and make a new |
| 169 // one to a fresh log file. | 167 // one to a fresh log file. |
| 170 base::FilePath target_path; | 168 base::FilePath target_path; |
| 171 bool symlink_exists = base::PathExists(symlink_path); | 169 bool symlink_exists = base::PathExists(symlink_path); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 189 } | 187 } |
| 190 | 188 |
| 191 void RemoveSymlinkAndLog(const base::FilePath& link_path, | 189 void RemoveSymlinkAndLog(const base::FilePath& link_path, |
| 192 const base::FilePath& target_path) { | 190 const base::FilePath& target_path) { |
| 193 if (::unlink(link_path.value().c_str()) == -1) | 191 if (::unlink(link_path.value().c_str()) == -1) |
| 194 DPLOG(WARNING) << "Unable to unlink symlink " << link_path.value(); | 192 DPLOG(WARNING) << "Unable to unlink symlink " << link_path.value(); |
| 195 if (::unlink(target_path.value().c_str()) == -1) | 193 if (::unlink(target_path.value().c_str()) == -1) |
| 196 DPLOG(WARNING) << "Unable to unlink log file " << target_path.value(); | 194 DPLOG(WARNING) << "Unable to unlink log file " << target_path.value(); |
| 197 } | 195 } |
| 198 | 196 |
| 199 } // anonymous namespace | |
| 200 | |
| 201 base::FilePath GetSessionLogDir(const base::CommandLine& command_line) { | 197 base::FilePath GetSessionLogDir(const base::CommandLine& command_line) { |
| 202 base::FilePath log_dir; | 198 base::FilePath log_dir; |
| 203 std::string log_dir_str; | 199 std::string log_dir_str; |
| 204 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 200 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
| 205 if (env->GetVar(env_vars::kSessionLogDir, &log_dir_str) && | 201 if (env->GetVar(env_vars::kSessionLogDir, &log_dir_str) && |
| 206 !log_dir_str.empty()) { | 202 !log_dir_str.empty()) { |
| 207 log_dir = base::FilePath(log_dir_str); | 203 log_dir = base::FilePath(log_dir_str); |
| 208 } else if (command_line.HasSwitch(chromeos::switches::kLoginProfile)) { | 204 } else if (command_line.HasSwitch(chromeos::switches::kLoginProfile)) { |
| 209 PathService::Get(chrome::DIR_USER_DATA, &log_dir); | 205 PathService::Get(chrome::DIR_USER_DATA, &log_dir); |
| 210 base::FilePath profile_dir; | 206 base::FilePath profile_dir; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 221 } | 217 } |
| 222 log_dir = log_dir.Append(profile_dir); | 218 log_dir = log_dir.Append(profile_dir); |
| 223 } | 219 } |
| 224 return log_dir; | 220 return log_dir; |
| 225 } | 221 } |
| 226 | 222 |
| 227 base::FilePath GetSessionLogFile(const base::CommandLine& command_line) { | 223 base::FilePath GetSessionLogFile(const base::CommandLine& command_line) { |
| 228 return GetSessionLogDir(command_line).Append(GetLogFileName().BaseName()); | 224 return GetSessionLogDir(command_line).Append(GetLogFileName().BaseName()); |
| 229 } | 225 } |
| 230 | 226 |
| 231 void RedirectChromeLogging(const base::CommandLine& command_line) { | |
| 232 if (chrome_logging_redirected_) { | |
| 233 // TODO(nkostylev): Support multiple active users. http://crbug.com/230345 | |
| 234 LOG(WARNING) << "NOT redirecting logging for multi-profiles case."; | |
| 235 return; | |
| 236 } | |
| 237 | |
| 238 DCHECK(!chrome_logging_redirected_) << | |
| 239 "Attempted to redirect logging when it was already initialized."; | |
| 240 | |
| 241 // Redirect logs to the session log directory, if set. Otherwise | |
| 242 // defaults to the profile dir. | |
| 243 base::FilePath log_path = GetSessionLogFile(command_line); | |
| 244 | |
| 245 // Creating symlink causes us to do blocking IO on UI thread. | |
| 246 // Temporarily allow it until we fix http://crbug.com/61143 | |
| 247 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
| 248 // Always force a new symlink when redirecting. | |
| 249 base::FilePath target_path = SetUpSymlinkIfNeeded(log_path, true); | |
| 250 | |
| 251 // ChromeOS always logs through the symlink, so it shouldn't be | |
| 252 // deleted if it already exists. | |
| 253 logging::LoggingSettings settings; | |
| 254 settings.logging_dest = DetermineLogMode(command_line); | |
| 255 settings.log_file = log_path.value().c_str(); | |
| 256 if (!logging::InitLogging(settings)) { | |
| 257 DLOG(ERROR) << "Unable to initialize logging to " << log_path.value(); | |
| 258 RemoveSymlinkAndLog(log_path, target_path); | |
| 259 } else { | |
| 260 chrome_logging_redirected_ = true; | |
| 261 } | |
| 262 } | |
| 263 | |
| 264 #endif // OS_CHROMEOS | 227 #endif // OS_CHROMEOS |
| 265 | 228 |
| 266 void InitChromeLogging(const base::CommandLine& command_line, | 229 void InitChromeLogging(const base::CommandLine& command_line, |
| 267 OldFileDeletionState delete_old_log_file) { | 230 OldFileDeletionState delete_old_log_file) { |
| 268 DCHECK(!chrome_logging_initialized_) << | 231 DCHECK(!chrome_logging_initialized_) << |
| 269 "Attempted to initialize logging when it was already initialized."; | 232 "Attempted to initialize logging when it was already initialized."; |
| 270 | 233 |
| 271 LoggingDestination logging_dest = DetermineLogMode(command_line); | 234 LoggingDestination logging_dest = DetermineLoggingDestination(command_line); |
| 272 LogLockingState log_locking_state = LOCK_LOG_FILE; | 235 LogLockingState log_locking_state = LOCK_LOG_FILE; |
| 273 base::FilePath log_path; | 236 base::FilePath log_path; |
| 274 #if defined(OS_CHROMEOS) | 237 #if defined(OS_CHROMEOS) |
| 275 base::FilePath target_path; | 238 base::FilePath target_path; |
| 276 #endif | 239 #endif |
| 277 | 240 |
| 278 // Don't resolve the log path unless we need to. Otherwise we leave an open | 241 // Don't resolve the log path unless we need to. Otherwise we leave an open |
| 279 // ALPC handle after sandbox lockdown on Windows. | 242 // ALPC handle after sandbox lockdown on Windows. |
| 280 if ((logging_dest & LOG_TO_FILE) != 0) { | 243 if ((logging_dest & LOG_TO_FILE) != 0) { |
| 281 log_path = GetLogFileName(); | 244 log_path = GetLogFileName(); |
| 282 | 245 |
| 283 #if defined(OS_CHROMEOS) | 246 #if defined(OS_CHROMEOS) |
| 284 // For BWSI (Incognito) logins, we want to put the logs in the user | 247 // For BWSI (Incognito) logins, we want to put the logs in the user |
| 285 // profile directory that is created for the temporary session instead | 248 // profile directory that is created for the temporary session instead |
| 286 // of in the system log directory, for privacy reasons. | 249 // of in the system log directory, for privacy reasons. |
| 287 if (command_line.HasSwitch(chromeos::switches::kGuestSession)) | 250 if (command_line.HasSwitch(chromeos::switches::kGuestSession)) |
| 288 log_path = GetSessionLogFile(command_line); | 251 log_path = GetSessionLogFile(command_line); |
| 289 | 252 |
| 290 // On ChromeOS we log to the symlink. We force creation of a new | 253 // On ChromeOS we log to the symlink. We force creation of a new |
| 291 // symlink if we've been asked to delete the old log, since that | 254 // symlink if we've been asked to delete the old log, since that |
| 292 // indicates the start of a new session. | 255 // indicates the start of a new session. |
| 293 target_path = SetUpSymlinkIfNeeded( | 256 target_path = SetUpSymlinkIfNeeded( |
| 294 log_path, delete_old_log_file == logging::DELETE_OLD_LOG_FILE); | 257 log_path, delete_old_log_file == DELETE_OLD_LOG_FILE); |
| 295 | 258 |
| 296 // Because ChromeOS manages the move to a new session by redirecting | 259 // Because ChromeOS manages the move to a new session by redirecting |
| 297 // the link, it shouldn't remove the old file in the logging code, | 260 // the link, it shouldn't remove the old file in the logging code, |
| 298 // since that will remove the newly created link instead. | 261 // since that will remove the newly created link instead. |
| 299 delete_old_log_file = logging::APPEND_TO_OLD_LOG_FILE; | 262 delete_old_log_file = APPEND_TO_OLD_LOG_FILE; |
| 300 #endif | 263 #endif |
| 301 } else { | 264 } else { |
| 302 log_locking_state = DONT_LOCK_LOG_FILE; | 265 log_locking_state = DONT_LOCK_LOG_FILE; |
| 303 } | 266 } |
| 304 | 267 |
| 305 logging::LoggingSettings settings; | 268 LoggingSettings settings; |
| 306 settings.logging_dest = logging_dest; | 269 settings.logging_dest = logging_dest; |
| 307 settings.log_file = log_path.value().c_str(); | 270 settings.log_file = log_path.value().c_str(); |
| 308 settings.lock_log = log_locking_state; | 271 settings.lock_log = log_locking_state; |
| 309 settings.delete_old = delete_old_log_file; | 272 settings.delete_old = delete_old_log_file; |
| 310 bool success = logging::InitLogging(settings); | 273 bool success = InitLogging(settings); |
| 311 | 274 |
| 312 #if defined(OS_CHROMEOS) | 275 #if defined(OS_CHROMEOS) |
| 313 if (!success) { | 276 if (!success) { |
| 314 DPLOG(ERROR) << "Unable to initialize logging to " << log_path.value() | 277 DPLOG(ERROR) << "Unable to initialize logging to " << log_path.value() |
| 315 << " (which should be a link to " << target_path.value() << ")"; | 278 << " (which should be a link to " << target_path.value() << ")"; |
| 316 RemoveSymlinkAndLog(log_path, target_path); | 279 RemoveSymlinkAndLog(log_path, target_path); |
| 317 chrome_logging_failed_ = true; | 280 chrome_logging_failed_ = true; |
| 318 return; | 281 return; |
| 319 } | 282 } |
| 320 #else | 283 #else |
| 321 if (!success) { | 284 if (!success) { |
| 322 DPLOG(ERROR) << "Unable to initialize logging to " << log_path.value(); | 285 DPLOG(ERROR) << "Unable to initialize logging to " << log_path.value(); |
| 323 chrome_logging_failed_ = true; | 286 chrome_logging_failed_ = true; |
| 324 return; | 287 return; |
| 325 } | 288 } |
| 326 #endif | 289 #endif |
| 327 | 290 |
| 328 // Default to showing error dialogs. | 291 // Default to showing error dialogs. |
| 329 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 292 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 330 switches::kNoErrorDialogs)) | 293 switches::kNoErrorDialogs)) |
| 331 logging::SetShowErrorDialogs(true); | 294 SetShowErrorDialogs(true); |
| 332 | 295 |
| 333 // we want process and thread IDs because we have a lot of things running | 296 // we want process and thread IDs because we have a lot of things running |
| 334 logging::SetLogItems(true, // enable_process_id | 297 SetLogItems(true, // enable_process_id |
| 335 true, // enable_thread_id | 298 true, // enable_thread_id |
| 336 true, // enable_timestamp | 299 true, // enable_timestamp |
| 337 false); // enable_tickcount | 300 false); // enable_tickcount |
| 338 | 301 |
| 339 // We call running in unattended mode "headless", and allow | 302 // We call running in unattended mode "headless", and allow |
| 340 // headless mode to be configured either by the Environment | 303 // headless mode to be configured either by the Environment |
| 341 // Variable or by the Command Line Switch. This is for | 304 // Variable or by the Command Line Switch. This is for |
| 342 // automated test purposes. | 305 // automated test purposes. |
| 343 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 306 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
| 344 if (env->HasVar(env_vars::kHeadless) || | 307 if (env->HasVar(env_vars::kHeadless) || |
| 345 command_line.HasSwitch(switches::kNoErrorDialogs)) | 308 command_line.HasSwitch(switches::kNoErrorDialogs)) |
| 346 SuppressDialogs(); | 309 SuppressDialogs(); |
| 347 | 310 |
| 348 // Use a minimum log level if the command line asks for one. Ignore this | 311 // Use a minimum log level if the command line asks for one. Ignore this |
| 349 // switch if there's vlog level switch present too (as both of these switches | 312 // switch if there's vlog level switch present too (as both of these switches |
| 350 // refer to the same underlying log level, and the vlog level switch has | 313 // refer to the same underlying log level, and the vlog level switch has |
| 351 // already been processed inside logging::InitLogging). If there is neither | 314 // already been processed inside InitLogging). If there is neither |
| 352 // log level nor vlog level specified, then just leave the default level | 315 // log level nor vlog level specified, then just leave the default level |
| 353 // (INFO). | 316 // (INFO). |
| 354 if (command_line.HasSwitch(switches::kLoggingLevel) && | 317 if (command_line.HasSwitch(switches::kLoggingLevel) && |
| 355 logging::GetMinLogLevel() >= 0) { | 318 GetMinLogLevel() >= 0) { |
| 356 std::string log_level = | 319 std::string log_level = |
| 357 command_line.GetSwitchValueASCII(switches::kLoggingLevel); | 320 command_line.GetSwitchValueASCII(switches::kLoggingLevel); |
| 358 int level = 0; | 321 int level = 0; |
| 359 if (base::StringToInt(log_level, &level) && level >= 0 && | 322 if (base::StringToInt(log_level, &level) && level >= 0 && |
| 360 level < LOG_NUM_SEVERITIES) { | 323 level < LOG_NUM_SEVERITIES) { |
| 361 logging::SetMinLogLevel(level); | 324 SetMinLogLevel(level); |
| 362 } else { | 325 } else { |
| 363 DLOG(WARNING) << "Bad log level: " << log_level; | 326 DLOG(WARNING) << "Bad log level: " << log_level; |
| 364 } | 327 } |
| 365 } | 328 } |
| 366 | 329 |
| 367 #if defined(OS_WIN) | 330 #if defined(OS_WIN) |
| 368 // Enable trace control and transport through event tracing for Windows. | 331 // Enable trace control and transport through event tracing for Windows. |
| 369 logging::LogEventProvider::Initialize(kChromeTraceProviderName); | 332 LogEventProvider::Initialize(kChromeTraceProviderName); |
| 370 | 333 |
| 371 // Enable logging to the Windows Event Log. | 334 // Enable logging to the Windows Event Log. |
| 372 logging::SetEventSourceName(base::UTF16ToASCII( | 335 SetEventSourceName(base::UTF16ToASCII( |
| 373 install_static::InstallDetails::Get().install_full_name())); | 336 install_static::InstallDetails::Get().install_full_name())); |
| 374 #endif | 337 #endif |
| 375 | 338 |
| 376 base::StatisticsRecorder::InitLogOnShutdown(); | 339 base::StatisticsRecorder::InitLogOnShutdown(); |
| 377 | 340 |
| 378 chrome_logging_initialized_ = true; | 341 chrome_logging_initialized_ = true; |
| 379 } | 342 } |
| 380 | 343 |
| 381 // This is a no-op, but we'll keep it around in case | 344 // This is a no-op, but we'll keep it around in case |
| 382 // we need to do more cleanup in the future. | 345 // we need to do more cleanup in the future. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 422 time_deets.year, | 385 time_deets.year, |
| 423 time_deets.month, | 386 time_deets.month, |
| 424 time_deets.day_of_month, | 387 time_deets.day_of_month, |
| 425 time_deets.hour, | 388 time_deets.hour, |
| 426 time_deets.minute, | 389 time_deets.minute, |
| 427 time_deets.second); | 390 time_deets.second); |
| 428 return base_path.InsertBeforeExtensionASCII(suffix); | 391 return base_path.InsertBeforeExtensionASCII(suffix); |
| 429 } | 392 } |
| 430 | 393 |
| 431 } // namespace logging | 394 } // namespace logging |
| OLD | NEW |