diff --git a/webrtc/overrides/webrtc/base/logging.cc b/webrtc/overrides/webrtc/base/logging.cc index 3ef28acd8b..5f5835e265 100644 --- a/webrtc/overrides/webrtc/base/logging.cc +++ b/webrtc/overrides/webrtc/base/logging.cc @@ -33,7 +33,7 @@ // DIAGNOSTIC_LOG. #define LOG_LAZY_STREAM_DIRECT(file_name, line_number, sev) \ LAZY_STREAM(logging::LogMessage(file_name, line_number, \ - -sev).stream(), true) + sev).stream(), true) namespace rtc { @@ -156,12 +156,19 @@ DiagnosticLogMessage::DiagnosticLogMessage(const char* file, } DiagnosticLogMessage::~DiagnosticLogMessage() { - print_stream_ << extra_; - const std::string& str = print_stream_.str(); - if (log_to_chrome_) - LOG_LAZY_STREAM_DIRECT(file_name_, line_, severity_) << str; - if (g_logging_delegate_function && severity_ <= LS_INFO) { - g_logging_delegate_function(str); + static_assert(LS_WARNING > LS_INFO, "LS_WARNING should be greater than INFO"); + static_assert(LS_ERROR > LS_INFO, "LS_ERROR should be greater than INFO"); + + const bool call_delegate = + g_logging_delegate_function && severity_ >= LS_INFO; + + if (call_delegate || log_to_chrome_) { + print_stream_ << extra_; + const std::string& str = print_stream_.str(); + if (log_to_chrome_) + LOG_LAZY_STREAM_DIRECT(file_name_, line_, severity_) << str; + if (call_delegate) + g_logging_delegate_function(str); } } diff --git a/webrtc/overrides/webrtc/base/logging.h b/webrtc/overrides/webrtc/base/logging.h index d9e0a35545..e8715c70e0 100644 --- a/webrtc/overrides/webrtc/base/logging.h +++ b/webrtc/overrides/webrtc/base/logging.h @@ -79,11 +79,11 @@ std::string ErrorName(int err, const ConstantLabel* err_table); // severity numbers than or equal to the current severity level are written to // file. Also, note that the values are explicitly defined here for convenience // since the command line flag must be set using numerical values. -enum LoggingSeverity { LS_ERROR = 1, - LS_WARNING = 2, - LS_INFO = 3, - LS_VERBOSE = 4, - LS_SENSITIVE = 5, +enum LoggingSeverity { LS_ERROR = logging::LOG_ERROR, + LS_WARNING = logging::LOG_WARNING, + LS_INFO = logging::LOG_INFO, + LS_VERBOSE = logging::LOG_VERBOSE, + LS_SENSITIVE = LS_VERBOSE - 1, INFO = LS_INFO, WARNING = LS_WARNING, LERROR = LS_ERROR };