Chromium Code Reviews| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 #if defined(OS_WIN) | 156 #if defined(OS_WIN) |
| 157 CloseHandle(log); | 157 CloseHandle(log); |
| 158 #else | 158 #else |
| 159 fclose(log); | 159 fclose(log); |
| 160 #endif | 160 #endif |
| 161 } | 161 } |
| 162 | 162 |
| 163 void DeleteFilePath(const PathString& log_name) { | 163 void DeleteFilePath(const PathString& log_name) { |
| 164 #if defined(OS_WIN) | 164 #if defined(OS_WIN) |
| 165 DeleteFile(log_name.c_str()); | 165 DeleteFile(log_name.c_str()); |
| 166 #elif defined (OS_NACL) | |
| 167 // Do nothing; unlink() isn't supported on NaCl. | |
| 166 #else | 168 #else |
| 167 unlink(log_name.c_str()); | 169 unlink(log_name.c_str()); |
| 168 #endif | 170 #endif |
| 169 } | 171 } |
| 170 | 172 |
| 171 PathString GetDefaultLogFile() { | 173 PathString GetDefaultLogFile() { |
| 172 #if defined(OS_WIN) | 174 #if defined(OS_WIN) |
| 173 // On Windows we use the same path as the exe. | 175 // On Windows we use the same path as the exe. |
| 174 wchar_t module_name[MAX_PATH]; | 176 wchar_t module_name[MAX_PATH]; |
| 175 GetModuleFileName(NULL, module_name, MAX_PATH); | 177 GetModuleFileName(NULL, module_name, MAX_PATH); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 } | 343 } |
| 342 | 344 |
| 343 } // namespace | 345 } // namespace |
| 344 | 346 |
| 345 | 347 |
| 346 bool BaseInitLoggingImpl(const PathChar* new_log_file, | 348 bool BaseInitLoggingImpl(const PathChar* new_log_file, |
| 347 LoggingDestination logging_dest, | 349 LoggingDestination logging_dest, |
| 348 LogLockingState lock_log, | 350 LogLockingState lock_log, |
| 349 OldFileDeletionState delete_old, | 351 OldFileDeletionState delete_old, |
| 350 DcheckState dcheck_state) { | 352 DcheckState dcheck_state) { |
| 351 g_dcheck_state = dcheck_state; | 353 g_dcheck_state = dcheck_state; |
|
dmichael (off chromium)
2013/04/10 23:10:22
Is it worth checking that LoggingDestination is ei
| |
| 352 // TODO(bbudge) Hook this up to NaCl logging. | |
| 353 #if !defined(OS_NACL) | |
| 354 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 354 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 355 // Don't bother initializing g_vlog_info unless we use one of the | 355 // Don't bother initializing g_vlog_info unless we use one of the |
| 356 // vlog switches. | 356 // vlog switches. |
| 357 if (command_line->HasSwitch(switches::kV) || | 357 if (command_line->HasSwitch(switches::kV) || |
| 358 command_line->HasSwitch(switches::kVModule)) { | 358 command_line->HasSwitch(switches::kVModule)) { |
| 359 // NOTE: If g_vlog_info has already been initialized, it might be in use | 359 // NOTE: If g_vlog_info has already been initialized, it might be in use |
| 360 // by another thread. Don't delete the old VLogInfo, just create a second | 360 // by another thread. Don't delete the old VLogInfo, just create a second |
| 361 // one. We keep track of both to avoid memory leak warnings. | 361 // one. We keep track of both to avoid memory leak warnings. |
| 362 CHECK(!g_vlog_info_prev); | 362 CHECK(!g_vlog_info_prev); |
| 363 g_vlog_info_prev = g_vlog_info; | 363 g_vlog_info_prev = g_vlog_info; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 386 logging_destination == LOG_ONLY_TO_SYSTEM_DEBUG_LOG) | 386 logging_destination == LOG_ONLY_TO_SYSTEM_DEBUG_LOG) |
| 387 return true; | 387 return true; |
| 388 | 388 |
| 389 if (!log_file_name) | 389 if (!log_file_name) |
| 390 log_file_name = new PathString(); | 390 log_file_name = new PathString(); |
| 391 *log_file_name = new_log_file; | 391 *log_file_name = new_log_file; |
| 392 if (delete_old == DELETE_OLD_LOG_FILE) | 392 if (delete_old == DELETE_OLD_LOG_FILE) |
| 393 DeleteFilePath(*log_file_name); | 393 DeleteFilePath(*log_file_name); |
| 394 | 394 |
| 395 return InitializeLogFileHandle(); | 395 return InitializeLogFileHandle(); |
| 396 #else | |
| 397 (void) g_vlog_info_prev; | |
| 398 return true; | |
| 399 #endif // !defined(OS_NACL) | |
| 400 } | 396 } |
| 401 | 397 |
| 402 void SetMinLogLevel(int level) { | 398 void SetMinLogLevel(int level) { |
| 403 min_log_level = std::min(LOG_ERROR_REPORT, level); | 399 min_log_level = std::min(LOG_ERROR_REPORT, level); |
| 404 } | 400 } |
| 405 | 401 |
| 406 int GetMinLogLevel() { | 402 int GetMinLogLevel() { |
| 407 return min_log_level; | 403 return min_log_level; |
| 408 } | 404 } |
| 409 | 405 |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 860 return *log_file_name; | 856 return *log_file_name; |
| 861 return std::wstring(); | 857 return std::wstring(); |
| 862 } | 858 } |
| 863 #endif | 859 #endif |
| 864 | 860 |
| 865 } // namespace logging | 861 } // namespace logging |
| 866 | 862 |
| 867 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { | 863 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { |
| 868 return out << WideToUTF8(std::wstring(wstr)); | 864 return out << WideToUTF8(std::wstring(wstr)); |
| 869 } | 865 } |
| OLD | NEW |