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

Unified Diff: base/logging_unittest.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/logging.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/logging_unittest.cc
diff --git a/base/logging_unittest.cc b/base/logging_unittest.cc
index e0619425f7542804b0c4604aba51603f619ef3b8..6953107132894595e8b37136ad4a00c2e5f75a9a 100644
--- a/base/logging_unittest.cc
+++ b/base/logging_unittest.cc
@@ -122,7 +122,7 @@ TEST_F(LoggingTest, LogIsOn) {
EXPECT_TRUE(kDfatalIsFatal == LOG_IS_ON(DFATAL));
}
-TEST_F(LoggingTest, LoggingIsLazy) {
+TEST_F(LoggingTest, LoggingIsLazyBySeverity) {
MockLogSource mock_log_source;
EXPECT_CALL(mock_log_source, Log()).Times(0);
@@ -151,6 +151,24 @@ TEST_F(LoggingTest, LoggingIsLazy) {
DVPLOG_IF(1, true) << mock_log_source.Log();
}
+TEST_F(LoggingTest, LoggingIsLazyByDestination) {
+ MockLogSource mock_log_source;
+ MockLogSource mock_log_source_error;
+ EXPECT_CALL(mock_log_source, Log()).Times(0);
+
+ // Severity >= ERROR is always printed to stderr.
+ EXPECT_CALL(mock_log_source_error, Log()).Times(1).
+ WillRepeatedly(Return("log message"));
+
+ LoggingSettings settings;
+ settings.logging_dest = LOG_NONE;
+ InitLogging(settings);
+
+ LOG(INFO) << mock_log_source.Log();
+ LOG(WARNING) << mock_log_source.Log();
+ LOG(ERROR) << mock_log_source_error.Log();
+}
+
// Official builds have CHECKs directly call BreakDebugger.
#if !defined(OFFICIAL_BUILD)
« no previous file with comments | « base/logging.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698