Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: base/logging.cc

Issue 1499693002: Don't evaluate args to LOG(INFO) and LOG(WARNING) in release builds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clarify comment Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/logging.h ('k') | base/logging_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // Return true here unless we know ~LogMessage won't do anything. Note that
398 // ~LogMessage writes to stderr if severity_ >= kAlwaysPrintErrorLevel, even
399 // when g_logging_destination is LOG_NONE.
400 return g_logging_destination != LOG_NONE || log_message_handler ||
401 severity >= kAlwaysPrintErrorLevel;
402 }
403
393 int GetVlogVerbosity() { 404 int GetVlogVerbosity() {
394 return std::max(-1, LOG_INFO - GetMinLogLevel()); 405 return std::max(-1, LOG_INFO - GetMinLogLevel());
395 } 406 }
396 407
397 int GetVlogLevelHelper(const char* file, size_t N) { 408 int GetVlogLevelHelper(const char* file, size_t N) {
398 DCHECK_GT(N, 0U); 409 DCHECK_GT(N, 0U);
399 // Note: |g_vlog_info| may change on a different thread during startup 410 // Note: |g_vlog_info| may change on a different thread during startup
400 // (but will always be valid or nullptr). 411 // (but will always be valid or nullptr).
401 VlogInfo* vlog_info = g_vlog_info; 412 VlogInfo* vlog_info = g_vlog_info;
402 return vlog_info ? 413 return vlog_info ?
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { 905 BASE_EXPORT void LogErrorNotReached(const char* file, int line) {
895 LogMessage(file, line, LOG_ERROR).stream() 906 LogMessage(file, line, LOG_ERROR).stream()
896 << "NOTREACHED() hit."; 907 << "NOTREACHED() hit.";
897 } 908 }
898 909
899 } // namespace logging 910 } // namespace logging
900 911
901 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { 912 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) {
902 return out << base::WideToUTF8(wstr); 913 return out << base::WideToUTF8(wstr);
903 } 914 }
OLDNEW
« no previous file with comments | « base/logging.h ('k') | base/logging_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698