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}
This commit is contained in:
Tommi 2015-05-14 04:18:26 +02:00
parent 99eeee39eb
commit a4463b2b8a
3 changed files with 21 additions and 2 deletions

View File

@ -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,

View File

@ -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 {

View File

@ -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( \