| 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 "base/logging.h" | 5 #include "base/logging.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <io.h> | 8 #include <io.h> |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 typedef HANDLE FileHandle; | 10 typedef HANDLE FileHandle; |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 } | 340 } |
| 341 | 341 |
| 342 } // namespace | 342 } // namespace |
| 343 | 343 |
| 344 | 344 |
| 345 bool BaseInitLoggingImpl(const PathChar* new_log_file, | 345 bool BaseInitLoggingImpl(const PathChar* new_log_file, |
| 346 LoggingDestination logging_dest, | 346 LoggingDestination logging_dest, |
| 347 LogLockingState lock_log, | 347 LogLockingState lock_log, |
| 348 OldFileDeletionState delete_old, | 348 OldFileDeletionState delete_old, |
| 349 DcheckState dcheck_state) { | 349 DcheckState dcheck_state) { |
| 350 g_dcheck_state = dcheck_state; |
| 351 // TODO(bbudge) Hook this up to NaCl logging. |
| 352 #if !defined(OS_NACL) |
| 350 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 353 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 351 g_dcheck_state = dcheck_state; | |
| 352 | |
| 353 // Don't bother initializing g_vlog_info unless we use one of the | 354 // Don't bother initializing g_vlog_info unless we use one of the |
| 354 // vlog switches. | 355 // vlog switches. |
| 355 if (command_line->HasSwitch(switches::kV) || | 356 if (command_line->HasSwitch(switches::kV) || |
| 356 command_line->HasSwitch(switches::kVModule)) { | 357 command_line->HasSwitch(switches::kVModule)) { |
| 357 // NOTE: If g_vlog_info has already been initialized, it might be in use | 358 // NOTE: If g_vlog_info has already been initialized, it might be in use |
| 358 // by another thread. Don't delete the old VLogInfo, just create a second | 359 // by another thread. Don't delete the old VLogInfo, just create a second |
| 359 // one. We keep track of both to avoid memory leak warnings. | 360 // one. We keep track of both to avoid memory leak warnings. |
| 360 CHECK(!g_vlog_info_prev); | 361 CHECK(!g_vlog_info_prev); |
| 361 g_vlog_info_prev = g_vlog_info; | 362 g_vlog_info_prev = g_vlog_info; |
| 362 | 363 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 384 logging_destination == LOG_ONLY_TO_SYSTEM_DEBUG_LOG) | 385 logging_destination == LOG_ONLY_TO_SYSTEM_DEBUG_LOG) |
| 385 return true; | 386 return true; |
| 386 | 387 |
| 387 if (!log_file_name) | 388 if (!log_file_name) |
| 388 log_file_name = new PathString(); | 389 log_file_name = new PathString(); |
| 389 *log_file_name = new_log_file; | 390 *log_file_name = new_log_file; |
| 390 if (delete_old == DELETE_OLD_LOG_FILE) | 391 if (delete_old == DELETE_OLD_LOG_FILE) |
| 391 DeleteFilePath(*log_file_name); | 392 DeleteFilePath(*log_file_name); |
| 392 | 393 |
| 393 return InitializeLogFileHandle(); | 394 return InitializeLogFileHandle(); |
| 395 #else |
| 396 return true; |
| 397 #endif // !defined(OS_NACL) |
| 394 } | 398 } |
| 395 | 399 |
| 396 void SetMinLogLevel(int level) { | 400 void SetMinLogLevel(int level) { |
| 397 min_log_level = std::min(LOG_ERROR_REPORT, level); | 401 min_log_level = std::min(LOG_ERROR_REPORT, level); |
| 398 } | 402 } |
| 399 | 403 |
| 400 int GetMinLogLevel() { | 404 int GetMinLogLevel() { |
| 401 return min_log_level; | 405 return min_log_level; |
| 402 } | 406 } |
| 403 | 407 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 std::string* result) | 549 std::string* result) |
| 546 : severity_(severity), file_(file), line_(line) { | 550 : severity_(severity), file_(file), line_(line) { |
| 547 Init(file, line); | 551 Init(file, line); |
| 548 stream_ << "Check failed: " << *result; | 552 stream_ << "Check failed: " << *result; |
| 549 delete result; | 553 delete result; |
| 550 } | 554 } |
| 551 | 555 |
| 552 LogMessage::~LogMessage() { | 556 LogMessage::~LogMessage() { |
| 553 // TODO(port): enable stacktrace generation on LOG_FATAL once backtrace are | 557 // TODO(port): enable stacktrace generation on LOG_FATAL once backtrace are |
| 554 // working in Android. | 558 // working in Android. |
| 555 #if !defined(NDEBUG) && !defined(OS_ANDROID) | 559 #if !defined(NDEBUG) && !defined(OS_ANDROID) && !defined(OS_NACL) |
| 556 if (severity_ == LOG_FATAL) { | 560 if (severity_ == LOG_FATAL) { |
| 557 // Include a stack trace on a fatal. | 561 // Include a stack trace on a fatal. |
| 558 base::debug::StackTrace trace; | 562 base::debug::StackTrace trace; |
| 559 stream_ << std::endl; // Newline to separate from log message. | 563 stream_ << std::endl; // Newline to separate from log message. |
| 560 trace.OutputToStream(&stream_); | 564 trace.OutputToStream(&stream_); |
| 561 } | 565 } |
| 562 #endif | 566 #endif |
| 563 stream_ << std::endl; | 567 stream_ << std::endl; |
| 564 std::string str_newline(stream_.str()); | 568 std::string str_newline(stream_.str()); |
| 565 | 569 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 } | 840 } |
| 837 | 841 |
| 838 // This was defined at the beginning of this file. | 842 // This was defined at the beginning of this file. |
| 839 #undef write | 843 #undef write |
| 840 | 844 |
| 841 } // namespace logging | 845 } // namespace logging |
| 842 | 846 |
| 843 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { | 847 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { |
| 844 return out << WideToUTF8(std::wstring(wstr)); | 848 return out << WideToUTF8(std::wstring(wstr)); |
| 845 } | 849 } |
| OLD | NEW |