| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 const int kMaxFilteredLogLevel = LOG_WARNING; | 75 const int kMaxFilteredLogLevel = LOG_WARNING; |
| 76 std::string* log_filter_prefix; | 76 std::string* log_filter_prefix; |
| 77 | 77 |
| 78 // For LOG_ERROR and above, always print to stderr. | 78 // For LOG_ERROR and above, always print to stderr. |
| 79 const int kAlwaysPrintErrorLevel = LOG_ERROR; | 79 const int kAlwaysPrintErrorLevel = LOG_ERROR; |
| 80 | 80 |
| 81 // Which log file to use? This is initialized by InitLogging or | 81 // Which log file to use? This is initialized by InitLogging or |
| 82 // will be lazily initialized to the default value when it is | 82 // will be lazily initialized to the default value when it is |
| 83 // first needed. | 83 // first needed. |
| 84 #if defined(OS_WIN) | 84 #if defined(OS_WIN) |
| 85 typedef wchar_t PathChar; | |
| 86 typedef std::wstring PathString; | 85 typedef std::wstring PathString; |
| 87 #else | 86 #else |
| 88 typedef char PathChar; | |
| 89 typedef std::string PathString; | 87 typedef std::string PathString; |
| 90 #endif | 88 #endif |
| 91 PathString* log_file_name = NULL; | 89 PathString* log_file_name = NULL; |
| 92 | 90 |
| 93 // this file is lazily opened and the handle may be NULL | 91 // this file is lazily opened and the handle may be NULL |
| 94 FileHandle log_file = NULL; | 92 FileHandle log_file = NULL; |
| 95 | 93 |
| 96 // what should be prepended to each message? | 94 // what should be prepended to each message? |
| 97 bool log_process_id = false; | 95 bool log_process_id = false; |
| 98 bool log_thread_id = false; | 96 bool log_thread_id = false; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 std::replace(safe_name.begin(), safe_name.end(), '\\', '/'); | 239 std::replace(safe_name.begin(), safe_name.end(), '\\', '/'); |
| 242 std::wstring t(L"Global\\"); | 240 std::wstring t(L"Global\\"); |
| 243 t.append(safe_name); | 241 t.append(safe_name); |
| 244 log_mutex = ::CreateMutex(NULL, FALSE, t.c_str()); | 242 log_mutex = ::CreateMutex(NULL, FALSE, t.c_str()); |
| 245 } | 243 } |
| 246 #elif defined(OS_POSIX) | 244 #elif defined(OS_POSIX) |
| 247 // statically initialized | 245 // statically initialized |
| 248 #endif | 246 #endif |
| 249 } | 247 } |
| 250 | 248 |
| 251 void InitLogging(const PathChar* new_log_file, LoggingDestination logging_dest, | 249 void BaseInitLoggingImpl(const PathChar* new_log_file, |
| 252 LogLockingState lock_log, OldFileDeletionState delete_old) { | 250 LoggingDestination logging_dest, |
| 251 LogLockingState lock_log, |
| 252 OldFileDeletionState delete_old) { |
| 253 g_enable_dcheck = | 253 g_enable_dcheck = |
| 254 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableDCHECK); | 254 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableDCHECK); |
| 255 | 255 |
| 256 if (log_file) { | 256 if (log_file) { |
| 257 // calling InitLogging twice or after some log call has already opened the | 257 // calling InitLogging twice or after some log call has already opened the |
| 258 // default log file will re-initialize to the new options | 258 // default log file will re-initialize to the new options |
| 259 CloseFile(log_file); | 259 CloseFile(log_file); |
| 260 log_file = NULL; | 260 log_file = NULL; |
| 261 } | 261 } |
| 262 | 262 |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 | 731 |
| 732 if (level == LOG_FATAL) | 732 if (level == LOG_FATAL) |
| 733 DebugUtil::BreakDebugger(); | 733 DebugUtil::BreakDebugger(); |
| 734 } | 734 } |
| 735 | 735 |
| 736 } // namespace logging | 736 } // namespace logging |
| 737 | 737 |
| 738 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { | 738 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { |
| 739 return out << WideToUTF8(std::wstring(wstr)); | 739 return out << WideToUTF8(std::wstring(wstr)); |
| 740 } | 740 } |
| OLD | NEW |