summaryrefslogtreecommitdiffstats
path: root/base/logging_unittest.cc
diff options
context:
space:
mode:
authorskobes <skobes@chromium.org>2015-12-07 12:21:23 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-07 20:22:13 +0000
commitc78c0ad7cca1b37761b488e9499d619b21c8016d (patch)
tree1e14a075d915fd00178a5923d9c6416cd238b4cb /base/logging_unittest.cc
parent09b359e586c35cf06a985dcf326a31aea4a1c6db (diff)
downloadchromium_src-c78c0ad7cca1b37761b488e9499d619b21c8016d.zip
chromium_src-c78c0ad7cca1b37761b488e9499d619b21c8016d.tar.gz
chromium_src-c78c0ad7cca1b37761b488e9499d619b21c8016d.tar.bz2
Don't evaluate args to LOG(INFO) and LOG(WARNING) in release builds.
We were using the LAZY_STREAM macro to do this based on --log-level (which defaults to INFO), but not for LoggingSettings::logging_dest == LOG_NONE. Review URL: https://codereview.chromium.org/1499693002 Cr-Commit-Position: refs/heads/master@{#363565}
Diffstat (limited to 'base/logging_unittest.cc')
-rw-r--r--base/logging_unittest.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/base/logging_unittest.cc b/base/logging_unittest.cc
index e061942..6953107 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)