Replace disabled logging with a restricted logging mode.
This will enable some low-level webrtc logging in a Chromium build, while limiting the binary size impact. For a Mac Release build, it results in an increase to Chrome.app of 37k and libpeerconnection.so of 25k. For comparison, enabling full logs costs 230k and 218k respectively. BUG=b/11470432 TESTED=voe_cmd_test produces logs of the appropriate severity. R=fischman@webrtc.org, henrikg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/3479004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5097 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
5adc89747a
commit
f1a48174d4
@ -127,10 +127,10 @@
|
||||
}],
|
||||
['build_with_libjingle==1', {
|
||||
'include_tests%': 0,
|
||||
'enable_tracing%': 0,
|
||||
'restrict_webrtc_logging%': 1,
|
||||
}, {
|
||||
'include_tests%': 1,
|
||||
'enable_tracing%': 1,
|
||||
'restrict_webrtc_logging%': 0,
|
||||
}],
|
||||
['OS=="ios"', {
|
||||
'build_libjpeg%': 0,
|
||||
@ -160,8 +160,8 @@
|
||||
#'WEBRTC_SVNREVISION="<!(python <(webrtc_root)/build/version.py)"',
|
||||
],
|
||||
'conditions': [
|
||||
['enable_tracing==1', {
|
||||
'defines': ['WEBRTC_LOGGING',],
|
||||
['restrict_webrtc_logging==1', {
|
||||
'defines': ['WEBRTC_RESTRICT_LOGGING',],
|
||||
}],
|
||||
['build_with_mozilla==1', {
|
||||
'defines': [
|
||||
|
@ -92,8 +92,6 @@ class LogMessage {
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LOG
|
||||
#if defined(WEBRTC_LOGGING)
|
||||
|
||||
// The following non-obvious technique for implementation of a
|
||||
// conditional log stream was stolen from google3/base/logging.h.
|
||||
|
||||
@ -109,8 +107,16 @@ class LogMessageVoidify {
|
||||
void operator&(std::ostream&) { }
|
||||
};
|
||||
|
||||
#if defined(WEBRTC_RESTRICT_LOGGING)
|
||||
// This should compile away logs matching the following condition.
|
||||
#define RESTRICT_LOGGING_PRECONDITION(sev) \
|
||||
sev < LS_INFO ? (void) 0 :
|
||||
#else
|
||||
#define RESTRICT_LOGGING_PRECONDITION(sev)
|
||||
#endif
|
||||
|
||||
#define LOG_SEVERITY_PRECONDITION(sev) \
|
||||
!(webrtc::LogMessage::Loggable(sev)) \
|
||||
RESTRICT_LOGGING_PRECONDITION(sev) !(webrtc::LogMessage::Loggable(sev)) \
|
||||
? (void) 0 \
|
||||
: webrtc::LogMessageVoidify() &
|
||||
|
||||
@ -131,19 +137,6 @@ class LogMessageVoidify {
|
||||
#define LOG_F(sev) LOG(sev) << __FUNCTION__ << ": "
|
||||
#endif
|
||||
|
||||
#else // !defined(WEBRTC_LOGGING)
|
||||
|
||||
// Hopefully, the compiler will optimize away some of this code.
|
||||
// Note: syntax of "1 ? (void)0 : LogMessage" was causing errors in g++,
|
||||
// converted to "while (false)"
|
||||
#define LOG(sev) \
|
||||
while (false)webrtc::LogMessage(NULL, 0, webrtc::sev).stream()
|
||||
#define LOG_V(sev) \
|
||||
while (false) webrtc::LogMessage(NULL, 0, sev).stream()
|
||||
#define LOG_F(sev) LOG(sev) << __FUNCTION__ << ": "
|
||||
|
||||
#endif // !defined(WEBRTC_LOGGING)
|
||||
|
||||
#define LOG_API0() LOG_F(LS_VERBOSE)
|
||||
#define LOG_API1(v1) LOG_API0() << #v1 << "=" << v1
|
||||
#define LOG_API2(v1, v2) LOG_API1(v1) \
|
||||
|
@ -19,14 +19,15 @@
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
#if !defined(WEBRTC_LOGGING)
|
||||
#define WEBRTC_TRACE (true) ? (void)0 : Trace::Add
|
||||
namespace webrtc {
|
||||
|
||||
#if defined(WEBRTC_RESTRICT_LOGGING)
|
||||
// Disable all TRACE macros. The LOG macro is still functional.
|
||||
#define WEBRTC_TRACE true ? (void) 0 : Trace::Add
|
||||
#else
|
||||
#define WEBRTC_TRACE Trace::Add
|
||||
#endif
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class Trace {
|
||||
public:
|
||||
// The length of the trace text preceeding the log message.
|
||||
|
@ -55,7 +55,7 @@ bool LogMessage::Loggable(LoggingSeverity sev) {
|
||||
|
||||
LogMessage::~LogMessage() {
|
||||
const std::string& str = print_stream_.str();
|
||||
WEBRTC_TRACE(WebRtcSeverity(severity_), kTraceUndefined, 0, str.c_str());
|
||||
Trace::Add(WebRtcSeverity(severity_), kTraceUndefined, 0, str.c_str());
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/system_wrappers/interface/logging.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
LogMessage::LogMessage(const char*, int, LoggingSeverity) {
|
||||
// Avoid an unused-private-field warning.
|
||||
(void)severity_;
|
||||
}
|
||||
|
||||
LogMessage::~LogMessage() {
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -85,7 +85,6 @@
|
||||
'list_no_stl.cc',
|
||||
'logcat_trace_context.cc',
|
||||
'logging.cc',
|
||||
'logging_no_op.cc',
|
||||
'rw_lock.cc',
|
||||
'rw_lock_generic.cc',
|
||||
'rw_lock_generic.h',
|
||||
@ -104,7 +103,6 @@
|
||||
'thread_win.h',
|
||||
'trace_impl.cc',
|
||||
'trace_impl.h',
|
||||
'trace_impl_no_op.cc',
|
||||
'trace_posix.cc',
|
||||
'trace_posix.h',
|
||||
'trace_win.cc',
|
||||
@ -116,22 +114,6 @@
|
||||
}, {
|
||||
'sources!': [ 'data_log.cc', ],
|
||||
},],
|
||||
['enable_tracing==1', {
|
||||
'sources!': [
|
||||
'logging_no_op.cc',
|
||||
'trace_impl_no_op.cc',
|
||||
],
|
||||
}, {
|
||||
'sources!': [
|
||||
'logging.cc',
|
||||
'trace_impl.cc',
|
||||
'trace_impl.h',
|
||||
'trace_posix.cc',
|
||||
'trace_posix.h',
|
||||
'trace_win.cc',
|
||||
'trace_win.h',
|
||||
],
|
||||
}],
|
||||
['OS=="android"', {
|
||||
'defines': [
|
||||
'WEBRTC_THREAD_RR',
|
||||
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
const int Trace::kBoilerplateLength = 71;
|
||||
const int Trace::kTimestampPosition = 13;
|
||||
const int Trace::kTimestampLength = 12;
|
||||
uint32_t Trace::level_filter_ = kTraceNone;
|
||||
|
||||
void Trace::CreateTrace() {
|
||||
}
|
||||
|
||||
void Trace::ReturnTrace() {
|
||||
}
|
||||
|
||||
int32_t Trace::TraceFile(char file_name[1024]) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t Trace::SetTraceFile(const char* file_name,
|
||||
const bool add_file_counter) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t Trace::SetTraceCallback(TraceCallback* callback) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Trace::Add(const TraceLevel level, const TraceModule module,
|
||||
const int32_t id, const char* msg, ...) {
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
Loading…
Reference in New Issue
Block a user