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 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
383 } | 383 } |
384 | 384 |
385 void SetMinLogLevel(int level) { | 385 void SetMinLogLevel(int level) { |
386 g_min_log_level = std::min(LOG_FATAL, level); | 386 g_min_log_level = std::min(LOG_FATAL, level); |
387 } | 387 } |
388 | 388 |
389 int GetMinLogLevel() { | 389 int GetMinLogLevel() { |
390 return g_min_log_level; | 390 return g_min_log_level; |
391 } | 391 } |
392 | 392 |
393 bool ShouldCreateLogMessage(int severity) { | |
394 if (severity < g_min_log_level) | |
395 return false; | |
396 | |
397 // These are the cases for which ~LogMessage does something. | |
398 return g_logging_destination != LOG_NONE || log_message_handler || | |
399 severity >= kAlwaysPrintErrorLevel; | |
brettw
2015/12/03 23:52:14
Do ew need the kAlwaysPrintErrorLevel check here?
skobes
2015/12/03 23:57:26
Yeah, ~LogMessage writes to stderr if severity_ >=
| |
400 } | |
401 | |
393 int GetVlogVerbosity() { | 402 int GetVlogVerbosity() { |
394 return std::max(-1, LOG_INFO - GetMinLogLevel()); | 403 return std::max(-1, LOG_INFO - GetMinLogLevel()); |
395 } | 404 } |
396 | 405 |
397 int GetVlogLevelHelper(const char* file, size_t N) { | 406 int GetVlogLevelHelper(const char* file, size_t N) { |
398 DCHECK_GT(N, 0U); | 407 DCHECK_GT(N, 0U); |
399 // Note: |g_vlog_info| may change on a different thread during startup | 408 // Note: |g_vlog_info| may change on a different thread during startup |
400 // (but will always be valid or nullptr). | 409 // (but will always be valid or nullptr). |
401 VlogInfo* vlog_info = g_vlog_info; | 410 VlogInfo* vlog_info = g_vlog_info; |
402 return vlog_info ? | 411 return vlog_info ? |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
894 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { | 903 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { |
895 LogMessage(file, line, LOG_ERROR).stream() | 904 LogMessage(file, line, LOG_ERROR).stream() |
896 << "NOTREACHED() hit."; | 905 << "NOTREACHED() hit."; |
897 } | 906 } |
898 | 907 |
899 } // namespace logging | 908 } // namespace logging |
900 | 909 |
901 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { | 910 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { |
902 return out << base::WideToUTF8(wstr); | 911 return out << base::WideToUTF8(wstr); |
903 } | 912 } |
OLD | NEW |