Fix logging in Chrome.
The constants we were using for severities don't match Chrome's, so I added a little translation function. A longer term fix could be to simply use the same values as in Chrome to not need the translation. That will however be a bigger change. BUG=chromium:401963 TBR=magjed@webrtc.org Review URL: https://webrtc-codereview.appspot.com/50949004 Cr-Commit-Position: refs/heads/master@{#9188}
This commit is contained in:
@ -70,6 +70,23 @@ enum LoggingSeverity { LS_ERROR = 1,
|
||||
WARNING = LS_WARNING,
|
||||
LERROR = LS_ERROR };
|
||||
|
||||
inline int WebRtcSevToChromeSev(LoggingSeverity sev) {
|
||||
switch (sev) {
|
||||
case LS_ERROR:
|
||||
return ::logging::LOG_ERROR;
|
||||
case LS_WARNING:
|
||||
return ::logging::LOG_WARNING;
|
||||
case LS_INFO:
|
||||
return ::logging::LOG_INFO;
|
||||
case LS_VERBOSE:
|
||||
case LS_SENSITIVE:
|
||||
return ::logging::LOG_VERBOSE;
|
||||
default:
|
||||
NOTREACHED();
|
||||
return ::logging::LOG_FATAL;
|
||||
}
|
||||
}
|
||||
|
||||
// LogErrorContext assists in interpreting the meaning of an error value.
|
||||
enum LogErrorContext {
|
||||
ERRCTX_NONE,
|
||||
|
@ -166,8 +166,11 @@ DiagnosticLogMessage::~DiagnosticLogMessage() {
|
||||
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 (log_to_chrome_) {
|
||||
LOG_LAZY_STREAM_DIRECT(file_name_, line_,
|
||||
rtc::WebRtcSevToChromeSev(severity_)) << str;
|
||||
}
|
||||
|
||||
if (g_logging_delegate_function && severity_ <= LS_INFO) {
|
||||
g_logging_delegate_function(str);
|
||||
}
|
||||
|
@ -38,13 +38,15 @@
|
||||
|
||||
#if defined(LOGGING_INSIDE_WEBRTC)
|
||||
|
||||
#define WEBRTC_VLOG_IS_ON(sev) VLOG_IS_ON(rtc::WebRtcSevToChromeSev(sev))
|
||||
|
||||
#define DIAGNOSTIC_LOG(sev, ctx, err, ...) \
|
||||
rtc::DiagnosticLogMessage( \
|
||||
__FILE__, __LINE__, sev, VLOG_IS_ON(sev), \
|
||||
__FILE__, __LINE__, sev, WEBRTC_VLOG_IS_ON(sev), \
|
||||
rtc::ERRCTX_ ## ctx, err, ##__VA_ARGS__).stream()
|
||||
|
||||
#define LOG_CHECK_LEVEL(sev) VLOG_IS_ON(rtc::sev)
|
||||
#define LOG_CHECK_LEVEL_V(sev) VLOG_IS_ON(sev)
|
||||
#define LOG_CHECK_LEVEL(sev) WEBRTC_VLOG_IS_ON(rtc::sev)
|
||||
#define LOG_CHECK_LEVEL_V(sev) WEBRTC_VLOG_IS_ON(sev)
|
||||
|
||||
#define LOG_V(sev) DIAGNOSTIC_LOG(sev, NONE, 0)
|
||||
#undef LOG
|
||||
|
Reference in New Issue
Block a user