From a4463b2b8a9f6a7dc6dc314b3a8de71712491b61 Mon Sep 17 00:00:00 2001 From: Tommi Date: Thu, 14 May 2015 04:18:26 +0200 Subject: [PATCH] Further updates to fix libjingle logging. Since libjingle log constant values decrease as severety goes up while Chrome's increase, I decided to handle the verbosity level check explicitly and convert libjingle severity over to chrome constants only when we log. This also requires updating the unittests on the Chrome side. BUG=chromium:401963 TBR=magjed@webrtc.org Review URL: https://webrtc-codereview.appspot.com/51839004 Cr-Commit-Position: refs/heads/master@{#9189} --- .../webrtc/base/diagnostic_logging.h | 19 +++++++++++++++++++ webrtc/overrides/webrtc/base/logging.cc | 2 +- webrtc/overrides/webrtc/base/logging.h | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/webrtc/overrides/webrtc/base/diagnostic_logging.h b/webrtc/overrides/webrtc/base/diagnostic_logging.h index 4cd80c83ff..a544ee5f7c 100644 --- a/webrtc/overrides/webrtc/base/diagnostic_logging.h +++ b/webrtc/overrides/webrtc/base/diagnostic_logging.h @@ -61,6 +61,8 @@ 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. +// TODO(tommi): To keep things simple, we should just use the same values for +// these constants as Chrome does. enum LoggingSeverity { LS_ERROR = 1, LS_WARNING = 2, LS_INFO = 3, @@ -87,6 +89,23 @@ inline int WebRtcSevToChromeSev(LoggingSeverity sev) { } } +inline int WebRtcVerbosityLevel(LoggingSeverity sev) { + switch (sev) { + case LS_ERROR: + return -2; + case LS_WARNING: + return -1; + case LS_INFO: // We treat 'info' and 'verbose' as the same verbosity level. + case LS_VERBOSE: + return 1; + case LS_SENSITIVE: + return 2; + default: + NOTREACHED(); + return 0; + } +} + // LogErrorContext assists in interpreting the meaning of an error value. enum LogErrorContext { ERRCTX_NONE, diff --git a/webrtc/overrides/webrtc/base/logging.cc b/webrtc/overrides/webrtc/base/logging.cc index fa86570b3f..55d7c7005b 100644 --- a/webrtc/overrides/webrtc/base/logging.cc +++ b/webrtc/overrides/webrtc/base/logging.cc @@ -37,7 +37,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 { diff --git a/webrtc/overrides/webrtc/base/logging.h b/webrtc/overrides/webrtc/base/logging.h index 8df2d19f46..ef471ee5e5 100644 --- a/webrtc/overrides/webrtc/base/logging.h +++ b/webrtc/overrides/webrtc/base/logging.h @@ -38,7 +38,7 @@ #if defined(LOGGING_INSIDE_WEBRTC) -#define WEBRTC_VLOG_IS_ON(sev) VLOG_IS_ON(rtc::WebRtcSevToChromeSev(sev)) +#define WEBRTC_VLOG_IS_ON(sev) VLOG_IS_ON(rtc::WebRtcVerbosityLevel(sev)) #define DIAGNOSTIC_LOG(sev, ctx, err, ...) \ rtc::DiagnosticLogMessage( \