Add a kTraceTerseInfo level for non-verbose logging.

Review URL: https://webrtc-codereview.appspot.com/937023

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3134 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org
2012-11-20 07:34:45 +00:00
parent 2009f6b236
commit 655d8f56f6
6 changed files with 30 additions and 13 deletions

View File

@@ -99,6 +99,9 @@ enum TraceLevel
kTraceDebug = 0x0800, // debug
kTraceInfo = 0x1000, // debug info
// Non-verbose level used by LS_INFO of logging.h. Do not use directly.
kTraceTerseInfo = 0x2000,
kTraceAll = 0xffff
};

View File

@@ -12,6 +12,13 @@
// It is a thin wrapper around WEBRTC_TRACE, maintaining the libjingle log
// semantics to ease a transition to that format.
// NOTE: LS_INFO maps to a new trace level which should be reserved for
// infrequent, non-verbose logs. The other levels below kTraceWarning have been
// rendered essentially useless due to their verbosity. Carefully consider the
// impact of adding a new LS_INFO log. If it will be logged at anything
// approaching a frame or packet frequency, use LS_VERBOSE if necessary, or
// preferably, do not log at all.
// LOG(...) an ostream target that can be used to send formatted
// output to a variety of logging targets, such as debugger console, stderr,
// file, or any StreamInterface.
@@ -38,7 +45,7 @@
//
// LOG_FERR is a shortcut for logging a failed function call. For example:
// if (!Foo(bar)) {
// LOG_FERR1(WARNING, Foo, bar);
// LOG_FERR1(LS_WARNING, Foo, bar);
// }
#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_LOGGING_H_
@@ -60,10 +67,9 @@ namespace webrtc {
// in debug builds.
// LS_WARNING: Something that may warrant investigation.
// LS_ERROR: Something that should not have occurred.
enum LoggingSeverity { LS_SENSITIVE, LS_VERBOSE, LS_INFO, LS_WARNING, LS_ERROR,
INFO = LS_INFO,
WARNING = LS_WARNING,
LERROR = LS_ERROR };
enum LoggingSeverity {
LS_SENSITIVE, LS_VERBOSE, LS_INFO, LS_WARNING, LS_ERROR
};
class LogMessage {
public:
@@ -144,7 +150,7 @@ class LogMessageVoidify {
#endif // !LOGGING
#define LOG_API0() LOG_F(LS_INFO)
#define LOG_API0() LOG_F(LS_VERBOSE)
#define LOG_API1(v1) LOG_API0() << #v1 << "=" << v1
#define LOG_API2(v1, v2) LOG_API1(v1) \
<< ", " << #v2 << "=" << v2

View File

@@ -22,8 +22,8 @@ static TraceLevel WebRtcSeverity(LoggingSeverity sev) {
switch (sev) {
// TODO(andrew): SENSITIVE doesn't have a corresponding webrtc level.
case LS_SENSITIVE: return kTraceInfo;
case LS_VERBOSE: return kTraceDebug;
case LS_INFO: return kTraceInfo;
case LS_VERBOSE: return kTraceInfo;
case LS_INFO: return kTraceTerseInfo;
case LS_WARNING: return kTraceWarning;
case LS_ERROR: return kTraceError;
default: return kTraceNone;

View File

@@ -72,7 +72,7 @@ TEST_F(LoggingTest, LogStream) {
level_ = kTraceWarning;
std::string msg = "Important message";
expected_log_ << "(logging_unittest.cc:" << __LINE__ + 1 << "): " << msg;
LOG(WARNING) << msg;
LOG(LS_WARNING) << msg;
cv_->SleepCS(*crit_.get());
}
}

View File

@@ -147,8 +147,14 @@ WebRtc_Word32 TraceImpl::AddThreadId(char* traceMessage) const {
WebRtc_Word32 TraceImpl::AddLevel(char* szMessage, const TraceLevel level) const
{
const int kMessageLength = 12;
switch (level)
{
case kTraceTerseInfo:
// Add the appropriate amount of whitespace.
memset(szMessage, ' ', kMessageLength);
szMessage[kMessageLength] = '\0';
break;
case kTraceStateInfo:
sprintf (szMessage, "STATEINFO ; ");
break;
@@ -187,7 +193,7 @@ WebRtc_Word32 TraceImpl::AddLevel(char* szMessage, const TraceLevel level) const
return 0;
}
// All messages are 12 characters.
return 12;
return kMessageLength;
}
WebRtc_Word32 TraceImpl::AddModuleAndId(char* traceMessage,
@@ -210,6 +216,7 @@ WebRtc_Word32 TraceImpl::AddModuleAndId(char* traceMessage,
case kTraceUndefined:
// Add the appropriate amount of whitespace.
memset(traceMessage, ' ', kMessageLength);
traceMessage[kMessageLength] = '\0';
break;
case kTraceVoice:
sprintf(traceMessage, " VOICE:%5ld %5ld;", idEngine,
@@ -287,6 +294,7 @@ WebRtc_Word32 TraceImpl::AddModuleAndId(char* traceMessage,
case kTraceUndefined:
// Add the appropriate amount of whitespace.
memset(traceMessage, ' ', kMessageLength);
traceMessage[kMessageLength] = '\0';
break;
case kTraceVoice:
sprintf (traceMessage, " VOICE:%11ld;", idl);

View File

@@ -6620,14 +6620,14 @@ int Channel::ApmProcessRx(AudioFrame& frame) {
AudioProcessing* audioproc = _rxAudioProcessingModulePtr;
// Register the (possibly new) frame parameters.
if (audioproc->set_sample_rate_hz(frame.sample_rate_hz_) != 0) {
LOG_FERR1(WARNING, set_sample_rate_hz, frame.sample_rate_hz_);
LOG_FERR1(LS_WARNING, set_sample_rate_hz, frame.sample_rate_hz_);
}
if (audioproc->set_num_channels(frame.num_channels_,
frame.num_channels_) != 0) {
LOG_FERR1(WARNING, set_num_channels, frame.num_channels_);
LOG_FERR1(LS_WARNING, set_num_channels, frame.num_channels_);
}
if (audioproc->ProcessStream(&frame) != 0) {
LOG_FERR0(WARNING, ProcessStream);
LOG_FERR0(LS_WARNING, ProcessStream);
}
return 0;
}