summaryrefslogtreecommitdiffstats
path: root/base/logging.cc
diff options
context:
space:
mode:
authorerikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-25 20:10:31 +0000
committererikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-25 20:10:31 +0000
commita33c9895d615ea1580a6e899cfb6f97fb2e0de07 (patch)
tree14a30b014743d8e2e22211d1c0ddd0a59bd7b114 /base/logging.cc
parentc26813bfca74edf2d0f290d0ab4fd7184c84f498 (diff)
downloadchromium_src-a33c9895d615ea1580a6e899cfb6f97fb2e0de07.zip
chromium_src-a33c9895d615ea1580a6e899cfb6f97fb2e0de07.tar.gz
chromium_src-a33c9895d615ea1580a6e899cfb6f97fb2e0de07.tar.bz2
When we're only outputting to a log file, above a certain log level, we should still output to stderr so that we can better detect and diagnose problems with unit tests, especially on the buildbots.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1323 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/logging.cc')
-rw-r--r--base/logging.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/base/logging.cc b/base/logging.cc
index 5b42825..da92f3c 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -63,6 +63,9 @@ LoggingDestination logging_destination = LOG_ONLY_TO_SYSTEM_DEBUG_LOG;
const int kMaxFilteredLogLevel = LOG_WARNING;
std::string* log_filter_prefix;
+// For LOG_ERROR and above, always print to stderr.
+const int kAlwaysPrintErrorLevel = LOG_ERROR;
+
// Which log file to use? This is initialized by InitLogging or
// will be lazily initialized to the default value when it is
// first needed.
@@ -410,9 +413,14 @@ LogMessage::~LogMessage() {
logging_destination == LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG) {
#if defined(OS_WIN)
OutputDebugStringA(str_newline.c_str());
-#else
- fprintf(stderr, "%s", str_newline.c_str());
#endif
+ // Output to stderr too so that unit tests can benefit as well.
+ fprintf(stderr, "%s", str_newline.c_str());
+ } else if (severity_ >= kAlwaysPrintErrorLevel) {
+ // When we're only outputting to a log file, above a certain log level, we
+ // should still output to stderr so that we can better detect and diagnose
+ // problems with unit tests, especially on the buildbots.
+ fprintf(stderr, "%s", str_newline.c_str());
}
// write to log file