Chromium Code Reviews| Index: overrides/webrtc/base/logging.cc |
| diff --git a/overrides/webrtc/base/logging.cc b/overrides/webrtc/base/logging.cc |
| index 98250a05c06e6c55577c358a3e25fbddabe0c2fa..b2c676faee3987273134b50d571c1c208fa57a4a 100644 |
| --- a/overrides/webrtc/base/logging.cc |
| +++ b/overrides/webrtc/base/logging.cc |
| @@ -8,11 +8,6 @@ |
| * be found in the AUTHORS file in the root of the source tree. |
| */ |
| -// IMPORTANT |
| -// Since this file includes Chromium source files, it must not include |
| -// logging.h since logging.h defines some of the same macros as Chrome does |
| -// and we'll run into conflict. |
| - |
| #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) |
| #include <CoreServices/CoreServices.h> |
| #endif // OS_MACOSX |
| @@ -21,6 +16,7 @@ |
| #include <iomanip> |
| #include "base/atomicops.h" |
| +#include "base/logging.h" |
| #include "base/strings/string_util.h" |
| #include "base/threading/platform_thread.h" |
| #include "third_party/webrtc/base/ipaddress.h" |
| @@ -29,13 +25,14 @@ |
| #include "third_party/webrtc/base/stringutils.h" |
| #include "third_party/webrtc/base/timeutils.h" |
| #include "third_party/webrtc/overrides/webrtc/base/diagnostic_logging.h" |
| +#include "third_party/webrtc/overrides/webrtc/base/logging.h" |
| // From this file we can't use VLOG since it expands into usage of the __FILE__ |
| // macro (for correct filtering). The actual logging call from DIAGNOSTIC_LOG in |
| // ~DiagnosticLogMessage. Note that the second parameter to the LAZY_STREAM |
| // macro is true since the filter check has already been done for |
| // DIAGNOSTIC_LOG. |
| -#define LOG_LAZY_STREAM_DIRECT(file_name, line_number, sev) \ |
| +#define LOG_LAZY_STREAM_DIRECT(file_name, line_number, sev) \ |
| RTC_LAZY_STREAM(logging::LogMessage(file_name, line_number, \ |
| sev).stream(), true) |
| @@ -79,6 +76,40 @@ std::string ErrorName(int err, const ConstantLabel* err_table) { |
| // Log helper functions |
| ///////////////////////////////////////////////////////////////////////////// |
| +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: |
| + RTC_NOTREACHED(); |
| + return ::logging::LOG_FATAL; |
| + } |
| +} |
| + |
| +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: |
| + RTC_NOTREACHED(); |
| + return 0; |
| + } |
| +} |
| + |
| // Generates extra information for LOG_E. |
| static std::string GenerateExtra(LogErrorContext err_ctx, |
| int err, |
| @@ -135,27 +166,25 @@ static std::string GenerateExtra(LogErrorContext err_ctx, |
| DiagnosticLogMessage::DiagnosticLogMessage(const char* file, |
| int line, |
| LoggingSeverity severity, |
| - bool log_to_chrome, |
| LogErrorContext err_ctx, |
| int err) |
| : file_name_(file), |
| line_(line), |
| severity_(severity), |
| - log_to_chrome_(log_to_chrome) { |
| + log_to_chrome_(CheckVlogIsOnHelper(severity, file, strlen(file) + 1)) { |
| extra_ = GenerateExtra(err_ctx, err, NULL); |
| } |
| DiagnosticLogMessage::DiagnosticLogMessage(const char* file, |
| int line, |
| LoggingSeverity severity, |
| - bool log_to_chrome, |
| LogErrorContext err_ctx, |
| int err, |
| const char* module) |
| : file_name_(file), |
| line_(line), |
| severity_(severity), |
| - log_to_chrome_(log_to_chrome) { |
| + log_to_chrome_(CheckVlogIsOnHelper(severity, file, strlen(file) + 1)) { |
| extra_ = GenerateExtra(err_ctx, err, module); |
| } |
| @@ -186,6 +215,8 @@ void LogMessage::LogToDebug(int min_sev) { |
| void LogMultiline(LoggingSeverity level, const char* label, bool input, |
| const void* data, size_t len, bool hex_mode, |
| LogMultilineState* state) { |
| + // TODO(grunell): This will not do the expected verbosity level checking. We |
| + // need a macro for the multiline logging. |
|
tommi
2015/09/15 15:06:29
is this worthy of a bug?
Henrik Grunell WebRTC
2015/09/17 07:50:17
Yes. https://code.google.com/p/webrtc/issues/detai
|
| if (!LOG_RTC_CHECK_LEVEL_V(level)) |
| return; |
| @@ -333,4 +364,10 @@ void SetExtraLoggingInit( |
| g_extra_logging_init_function = function; |
| } |
| +bool CheckVlogIsOnHelper( |
| + rtc::LoggingSeverity severity, const char* file, size_t N) { |
| + return rtc::WebRtcVerbosityLevel(severity) <= |
| + ::logging::GetVlogLevelHelper(file, N); |
| +} |
| + |
| } // namespace rtc |