| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 #if defined(OS_POSIX) | 58 #if defined(OS_POSIX) |
| 59 #include "base/safe_strerror_posix.h" | 59 #include "base/safe_strerror_posix.h" |
| 60 #endif | 60 #endif |
| 61 | 61 |
| 62 #if defined(OS_ANDROID) | 62 #if defined(OS_ANDROID) |
| 63 #include <android/log.h> | 63 #include <android/log.h> |
| 64 #endif | 64 #endif |
| 65 | 65 |
| 66 namespace logging { | 66 namespace logging { |
| 67 | 67 |
| 68 DcheckState g_dcheck_state = DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS; | |
| 69 | |
| 70 void set_dcheck_state(DcheckState state) { | |
| 71 g_dcheck_state = state; | |
| 72 } | |
| 73 | |
| 74 namespace { | 68 namespace { |
| 75 | 69 |
| 76 VlogInfo* g_vlog_info = NULL; | 70 VlogInfo* g_vlog_info = NULL; |
| 77 VlogInfo* g_vlog_info_prev = NULL; | 71 VlogInfo* g_vlog_info_prev = NULL; |
| 78 | 72 |
| 79 const char* const log_severity_names[LOG_NUM_SEVERITIES] = { | 73 const char* const log_severity_names[LOG_NUM_SEVERITIES] = { |
| 80 "INFO", "WARNING", "ERROR", "ERROR_REPORT", "FATAL" }; | 74 "INFO", "WARNING", "ERROR", "ERROR_REPORT", "FATAL" }; |
| 81 | 75 |
| 82 const char* log_severity_name(int severity) | 76 const char* log_severity_name(int severity) |
| 83 { | 77 { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 CloseFile(log_file); | 345 CloseFile(log_file); |
| 352 log_file = NULL; | 346 log_file = NULL; |
| 353 } | 347 } |
| 354 | 348 |
| 355 } // namespace | 349 } // namespace |
| 356 | 350 |
| 357 LoggingSettings::LoggingSettings() | 351 LoggingSettings::LoggingSettings() |
| 358 : logging_dest(LOG_DEFAULT), | 352 : logging_dest(LOG_DEFAULT), |
| 359 log_file(NULL), | 353 log_file(NULL), |
| 360 lock_log(LOCK_LOG_FILE), | 354 lock_log(LOCK_LOG_FILE), |
| 361 delete_old(APPEND_TO_OLD_LOG_FILE), | 355 delete_old(APPEND_TO_OLD_LOG_FILE) {} |
| 362 dcheck_state(DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS) {} | |
| 363 | 356 |
| 364 bool BaseInitLoggingImpl(const LoggingSettings& settings) { | 357 bool BaseInitLoggingImpl(const LoggingSettings& settings) { |
| 365 #if defined(OS_NACL) | 358 #if defined(OS_NACL) |
| 366 // Can log only to the system debug log. | 359 // Can log only to the system debug log. |
| 367 CHECK_EQ(settings.logging_dest & ~LOG_TO_SYSTEM_DEBUG_LOG, 0); | 360 CHECK_EQ(settings.logging_dest & ~LOG_TO_SYSTEM_DEBUG_LOG, 0); |
| 368 #endif | 361 #endif |
| 369 g_dcheck_state = settings.dcheck_state; | |
| 370 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 362 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 371 // Don't bother initializing g_vlog_info unless we use one of the | 363 // Don't bother initializing g_vlog_info unless we use one of the |
| 372 // vlog switches. | 364 // vlog switches. |
| 373 if (command_line->HasSwitch(switches::kV) || | 365 if (command_line->HasSwitch(switches::kV) || |
| 374 command_line->HasSwitch(switches::kVModule)) { | 366 command_line->HasSwitch(switches::kVModule)) { |
| 375 // NOTE: If g_vlog_info has already been initialized, it might be in use | 367 // NOTE: If g_vlog_info has already been initialized, it might be in use |
| 376 // by another thread. Don't delete the old VLogInfo, just create a second | 368 // by another thread. Don't delete the old VLogInfo, just create a second |
| 377 // one. We keep track of both to avoid memory leak warnings. | 369 // one. We keep track of both to avoid memory leak warnings. |
| 378 CHECK(!g_vlog_info_prev); | 370 CHECK(!g_vlog_info_prev); |
| 379 g_vlog_info_prev = g_vlog_info; | 371 g_vlog_info_prev = g_vlog_info; |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 return *log_file_name; | 847 return *log_file_name; |
| 856 return std::wstring(); | 848 return std::wstring(); |
| 857 } | 849 } |
| 858 #endif | 850 #endif |
| 859 | 851 |
| 860 } // namespace logging | 852 } // namespace logging |
| 861 | 853 |
| 862 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { | 854 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { |
| 863 return out << base::WideToUTF8(std::wstring(wstr)); | 855 return out << base::WideToUTF8(std::wstring(wstr)); |
| 864 } | 856 } |
| OLD | NEW |