Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Unified Diff: webrtc/overrides/webrtc/base/logging.cc

Issue 1338763002: Remove dependency on Chromium in diagnostic_logging.h. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc/trunk/webrtc.git@rename_checks
Patch Set: Added bug in comment. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/overrides/webrtc/base/logging.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/overrides/webrtc/base/logging.cc
diff --git a/webrtc/overrides/webrtc/base/logging.cc b/webrtc/overrides/webrtc/base/logging.cc
index 58a834de3f29f325c79523b89bc601638d79a1d9..27254e3421c907c297f506e4c7d3c6260fa498c5 100644
--- a/webrtc/overrides/webrtc/base/logging.cc
+++ b/webrtc/overrides/webrtc/base/logging.cc
@@ -9,9 +9,9 @@
*/
// 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.
+// Since this file includes Chromium headers, it must not include
+// third_party/webrtc/base/logging.h since it defines some of the same macros as
+// Chromium does and we'll run into conflicts.
#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
#include <CoreServices/CoreServices.h>
@@ -21,6 +21,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"
@@ -79,6 +80,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:
+ 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:
+ NOTREACHED();
+ return 0;
+ }
+}
+
// Generates extra information for LOG_E.
static std::string GenerateExtra(LogErrorContext err_ctx,
int err,
@@ -135,27 +170,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 +219,9 @@ 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.
+ // https://code.google.com/p/webrtc/issues/detail?id=5011
if (!LOG_CHECK_LEVEL_V(level))
return;
@@ -333,4 +369,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
« no previous file with comments | « webrtc/overrides/webrtc/base/logging.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698