OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 FilePath log_path = GetSessionLogFile(command_line); | 238 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 FilePath target_path = SetUpSymlinkIfNeeded(log_path, true); | 244 FilePath target_path = SetUpSymlinkIfNeeded(log_path, true); |
245 | 245 |
246 #if defined(DCHECK_ALWAYS_ON) | |
247 logging::DcheckState dcheck_state = | |
248 logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS | |
249 #else | |
246 logging::DcheckState dcheck_state = | 250 logging::DcheckState dcheck_state = |
247 command_line.HasSwitch(switches::kEnableDCHECK) ? | 251 command_line.HasSwitch(switches::kEnableDCHECK) ? |
248 logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS : | 252 logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS : |
249 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS; | 253 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS; |
254 #endif | |
250 | 255 |
251 // ChromeOS always logs through the symlink, so it shouldn't be | 256 // ChromeOS always logs through the symlink, so it shouldn't be |
252 // deleted if it already exists. | 257 // deleted if it already exists. |
253 if (!InitLogging(log_path.value().c_str(), | 258 if (!InitLogging(log_path.value().c_str(), |
254 DetermineLogMode(command_line), | 259 DetermineLogMode(command_line), |
255 logging::LOCK_LOG_FILE, | 260 logging::LOCK_LOG_FILE, |
256 logging::APPEND_TO_OLD_LOG_FILE, | 261 logging::APPEND_TO_OLD_LOG_FILE, |
257 dcheck_state)) { | 262 dcheck_state)) { |
258 LOG(ERROR) << "Unable to initialize logging to " << log_path.value(); | 263 LOG(ERROR) << "Unable to initialize logging to " << log_path.value(); |
259 RemoveSymlinkAndLog(log_path, target_path); | 264 RemoveSymlinkAndLog(log_path, target_path); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 target_path = SetUpSymlinkIfNeeded( | 302 target_path = SetUpSymlinkIfNeeded( |
298 log_path, delete_old_log_file == logging::DELETE_OLD_LOG_FILE); | 303 log_path, delete_old_log_file == logging::DELETE_OLD_LOG_FILE); |
299 | 304 |
300 // Because ChromeOS manages the move to a new session by redirecting | 305 // Because ChromeOS manages the move to a new session by redirecting |
301 // the link, it shouldn't remove the old file in the logging code, | 306 // the link, it shouldn't remove the old file in the logging code, |
302 // since that will remove the newly created link instead. | 307 // since that will remove the newly created link instead. |
303 delete_old_log_file = logging::APPEND_TO_OLD_LOG_FILE; | 308 delete_old_log_file = logging::APPEND_TO_OLD_LOG_FILE; |
304 #endif | 309 #endif |
305 } | 310 } |
306 | 311 |
312 #if defined(DCHECK_ALWAYS_ON) | |
313 logging::DcheckState dcheck_state = | |
314 logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS | |
315 #else | |
307 logging::DcheckState dcheck_state = | 316 logging::DcheckState dcheck_state = |
308 command_line.HasSwitch(switches::kEnableDCHECK) ? | 317 command_line.HasSwitch(switches::kEnableDCHECK) ? |
309 logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS : | 318 logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS : |
310 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS; | 319 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS; |
320 #endif | |
311 | 321 |
312 bool success = InitLogging(log_path.value().c_str(), | 322 bool success = InitLogging(log_path.value().c_str(), |
313 logging_dest, | 323 logging_dest, |
314 logging::LOCK_LOG_FILE, | 324 logging::LOCK_LOG_FILE, |
315 delete_old_log_file, | 325 delete_old_log_file, |
316 dcheck_state); | 326 dcheck_state); |
317 | 327 |
318 #if defined(OS_CHROMEOS) | 328 #if defined(OS_CHROMEOS) |
319 if (!success) { | 329 if (!success) { |
320 PLOG(ERROR) << "Unable to initialize logging to " << log_path.value() | 330 PLOG(ERROR) << "Unable to initialize logging to " << log_path.value() |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
365 } | 375 } |
366 | 376 |
367 #if defined(OS_WIN) | 377 #if defined(OS_WIN) |
368 // Enable trace control and transport through event tracing for Windows. | 378 // Enable trace control and transport through event tracing for Windows. |
369 if (env->HasVar(env_vars::kEtwLogging)) | 379 if (env->HasVar(env_vars::kEtwLogging)) |
370 logging::LogEventProvider::Initialize(kChromeTraceProviderName); | 380 logging::LogEventProvider::Initialize(kChromeTraceProviderName); |
371 #endif | 381 #endif |
372 | 382 |
373 #ifdef NDEBUG | 383 #ifdef NDEBUG |
374 if (command_line.HasSwitch(switches::kSilentDumpOnDCHECK) && | 384 if (command_line.HasSwitch(switches::kSilentDumpOnDCHECK) && |
375 command_line.HasSwitch(switches::kEnableDCHECK)) { | 385 command_line.HasSwitch(switches::kEnableDCHECK)) { |
rvargas (doing something else)
2011/08/23 20:48:22
Looks like we need another condition here :(
| |
376 #if defined(OS_WIN) | 386 #if defined(OS_WIN) |
377 logging::SetLogReportHandler(DumpProcessAssertHandler); | 387 logging::SetLogReportHandler(DumpProcessAssertHandler); |
378 #endif | 388 #endif |
379 } | 389 } |
380 #endif // NDEBUG | 390 #endif // NDEBUG |
381 | 391 |
382 chrome_logging_initialized_ = true; | 392 chrome_logging_initialized_ = true; |
383 } | 393 } |
384 | 394 |
385 // This is a no-op, but we'll keep it around in case | 395 // This is a no-op, but we'll keep it around in case |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
446 assertions->push_back(wide_line); | 456 assertions->push_back(wide_line); |
447 ++assertion_count; | 457 ++assertion_count; |
448 } | 458 } |
449 } | 459 } |
450 log_file.close(); | 460 log_file.close(); |
451 | 461 |
452 return assertion_count; | 462 return assertion_count; |
453 } | 463 } |
454 | 464 |
455 } // namespace logging | 465 } // namespace logging |
OLD | NEW |