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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // Redirect logs to the session log directory, if set. Otherwise | 236 // Redirect logs to the session log directory, if set. Otherwise |
237 // defaults to the profile dir. | 237 // defaults to the profile dir. |
238 base::FilePath log_path = GetSessionLogFile(command_line); | 238 base::FilePath log_path = GetSessionLogFile(command_line); |
239 | 239 |
240 // Creating symlink causes us to do blocking IO on UI thread. | 240 // Creating symlink causes us to do blocking IO on UI thread. |
241 // Temporarily allow it until we fix http://crbug.com/61143 | 241 // Temporarily allow it until we fix http://crbug.com/61143 |
242 base::ThreadRestrictions::ScopedAllowIO allow_io; | 242 base::ThreadRestrictions::ScopedAllowIO allow_io; |
243 // Always force a new symlink when redirecting. | 243 // Always force a new symlink when redirecting. |
244 base::FilePath target_path = SetUpSymlinkIfNeeded(log_path, true); | 244 base::FilePath target_path = SetUpSymlinkIfNeeded(log_path, true); |
245 | 245 |
246 logging::DcheckState dcheck_state = | |
247 command_line.HasSwitch(switches::kEnableDCHECK) ? | |
248 logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS : | |
249 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS; | |
250 | |
251 // ChromeOS always logs through the symlink, so it shouldn't be | 246 // ChromeOS always logs through the symlink, so it shouldn't be |
252 // deleted if it already exists. | 247 // deleted if it already exists. |
253 logging::LoggingSettings settings; | 248 logging::LoggingSettings settings; |
254 settings.logging_dest = DetermineLogMode(command_line); | 249 settings.logging_dest = DetermineLogMode(command_line); |
255 settings.log_file = log_path.value().c_str(); | 250 settings.log_file = log_path.value().c_str(); |
256 settings.dcheck_state = dcheck_state; | |
257 if (!logging::InitLogging(settings)) { | 251 if (!logging::InitLogging(settings)) { |
258 DLOG(ERROR) << "Unable to initialize logging to " << log_path.value(); | 252 DLOG(ERROR) << "Unable to initialize logging to " << log_path.value(); |
259 RemoveSymlinkAndLog(log_path, target_path); | 253 RemoveSymlinkAndLog(log_path, target_path); |
260 } else { | 254 } else { |
261 chrome_logging_redirected_ = true; | 255 chrome_logging_redirected_ = true; |
262 } | 256 } |
263 } | 257 } |
264 | 258 |
265 #endif // OS_CHROMEOS | 259 #endif // OS_CHROMEOS |
266 | 260 |
(...skipping 29 matching lines...) Expand all Loading... |
296 | 290 |
297 // Because ChromeOS manages the move to a new session by redirecting | 291 // Because ChromeOS manages the move to a new session by redirecting |
298 // the link, it shouldn't remove the old file in the logging code, | 292 // the link, it shouldn't remove the old file in the logging code, |
299 // since that will remove the newly created link instead. | 293 // since that will remove the newly created link instead. |
300 delete_old_log_file = logging::APPEND_TO_OLD_LOG_FILE; | 294 delete_old_log_file = logging::APPEND_TO_OLD_LOG_FILE; |
301 #endif | 295 #endif |
302 } else { | 296 } else { |
303 log_locking_state = DONT_LOCK_LOG_FILE; | 297 log_locking_state = DONT_LOCK_LOG_FILE; |
304 } | 298 } |
305 | 299 |
306 logging::DcheckState dcheck_state = | |
307 command_line.HasSwitch(switches::kEnableDCHECK) ? | |
308 logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS : | |
309 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS; | |
310 | |
311 logging::LoggingSettings settings; | 300 logging::LoggingSettings settings; |
312 settings.logging_dest = logging_dest; | 301 settings.logging_dest = logging_dest; |
313 settings.log_file = log_path.value().c_str(); | 302 settings.log_file = log_path.value().c_str(); |
314 settings.lock_log = log_locking_state; | 303 settings.lock_log = log_locking_state; |
315 settings.delete_old = delete_old_log_file; | 304 settings.delete_old = delete_old_log_file; |
316 settings.dcheck_state = dcheck_state; | |
317 bool success = logging::InitLogging(settings); | 305 bool success = logging::InitLogging(settings); |
318 | 306 |
319 #if defined(OS_CHROMEOS) | 307 #if defined(OS_CHROMEOS) |
320 if (!success) { | 308 if (!success) { |
321 DPLOG(ERROR) << "Unable to initialize logging to " << log_path.value() | 309 DPLOG(ERROR) << "Unable to initialize logging to " << log_path.value() |
322 << " (which should be a link to " << target_path.value() << ")"; | 310 << " (which should be a link to " << target_path.value() << ")"; |
323 RemoveSymlinkAndLog(log_path, target_path); | 311 RemoveSymlinkAndLog(log_path, target_path); |
324 chrome_logging_failed_ = true; | 312 chrome_logging_failed_ = true; |
325 return; | 313 return; |
326 } | 314 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 DLOG(WARNING) << "Bad log level: " << log_level; | 352 DLOG(WARNING) << "Bad log level: " << log_level; |
365 } | 353 } |
366 } | 354 } |
367 | 355 |
368 #if defined(OS_WIN) | 356 #if defined(OS_WIN) |
369 // Enable trace control and transport through event tracing for Windows. | 357 // Enable trace control and transport through event tracing for Windows. |
370 logging::LogEventProvider::Initialize(kChromeTraceProviderName); | 358 logging::LogEventProvider::Initialize(kChromeTraceProviderName); |
371 #endif | 359 #endif |
372 | 360 |
373 #ifdef NDEBUG | 361 #ifdef NDEBUG |
374 if (command_line.HasSwitch(switches::kSilentDumpOnDCHECK) && | 362 if (command_line.HasSwitch(switches::kSilentDumpOnDCHECK) && DCHECK_IS_ON()) { |
375 command_line.HasSwitch(switches::kEnableDCHECK)) { | |
376 #if defined(OS_WIN) | 363 #if defined(OS_WIN) |
377 logging::SetLogReportHandler(DumpProcessAssertHandler); | 364 logging::SetLogReportHandler(DumpProcessAssertHandler); |
378 #endif | 365 #endif |
379 } | 366 } |
380 #endif // NDEBUG | 367 #endif // NDEBUG |
381 | 368 |
382 chrome_logging_initialized_ = true; | 369 chrome_logging_initialized_ = true; |
383 } | 370 } |
384 | 371 |
385 // This is a no-op, but we'll keep it around in case | 372 // This is a no-op, but we'll keep it around in case |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 time_deets.year, | 442 time_deets.year, |
456 time_deets.month, | 443 time_deets.month, |
457 time_deets.day_of_month, | 444 time_deets.day_of_month, |
458 time_deets.hour, | 445 time_deets.hour, |
459 time_deets.minute, | 446 time_deets.minute, |
460 time_deets.second); | 447 time_deets.second); |
461 return base_path.InsertBeforeExtensionASCII(suffix); | 448 return base_path.InsertBeforeExtensionASCII(suffix); |
462 } | 449 } |
463 | 450 |
464 } // namespace logging | 451 } // namespace logging |
OLD | NEW |