Delete system_wrappers logging facility.
BUG=webrtc:5118 Review-Url: https://codereview.webrtc.org/2796353002 Cr-Commit-Position: refs/heads/master@{#17561}
This commit is contained in:
@ -15,11 +15,11 @@
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/modules/audio_processing/aec3/aec3_common.h"
|
||||
#include "webrtc/modules/audio_processing/aec3/block_processor.h"
|
||||
#include "webrtc/modules/audio_processing/aec3/decimator_by_4.h"
|
||||
#include "webrtc/modules/audio_processing/aec3/fft_data.h"
|
||||
#include "webrtc/system_wrappers/include/logging.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
@ -34,7 +34,6 @@
|
||||
#include "webrtc/sdk/android/src/jni/classreferenceholder.h"
|
||||
#include "webrtc/sdk/android/src/jni/native_handle_impl.h"
|
||||
#include "webrtc/sdk/android/src/jni/surfacetexturehelper_jni.h"
|
||||
#include "webrtc/system_wrappers/include/logcat_trace_context.h"
|
||||
|
||||
using rtc::Bind;
|
||||
using rtc::Thread;
|
||||
|
||||
@ -42,7 +42,6 @@
|
||||
#include "webrtc/sdk/android/src/jni/classreferenceholder.h"
|
||||
#include "webrtc/sdk/android/src/jni/native_handle_impl.h"
|
||||
#include "webrtc/system_wrappers/include/field_trial.h"
|
||||
#include "webrtc/system_wrappers/include/logcat_trace_context.h"
|
||||
|
||||
using rtc::Bind;
|
||||
using rtc::Thread;
|
||||
|
||||
@ -24,7 +24,6 @@ rtc_static_library("system_wrappers") {
|
||||
"include/field_trial.h",
|
||||
"include/file_wrapper.h",
|
||||
"include/fix_interlocked_exchange_pointer_win.h",
|
||||
"include/logging.h",
|
||||
"include/metrics.h",
|
||||
"include/ntp_time.h",
|
||||
"include/rtp_to_ntp_estimator.h",
|
||||
@ -45,7 +44,6 @@ rtc_static_library("system_wrappers") {
|
||||
"source/event_timer_win.cc",
|
||||
"source/event_timer_win.h",
|
||||
"source/file_impl.cc",
|
||||
"source/logging.cc",
|
||||
"source/rtp_to_ntp_estimator.cc",
|
||||
"source/rw_lock.cc",
|
||||
"source/rw_lock_posix.cc",
|
||||
@ -167,7 +165,6 @@ if (rtc_include_tests) {
|
||||
"source/aligned_malloc_unittest.cc",
|
||||
"source/clock_unittest.cc",
|
||||
"source/event_timer_posix_unittest.cc",
|
||||
"source/logging_unittest.cc",
|
||||
"source/metrics_default_unittest.cc",
|
||||
"source/metrics_unittest.cc",
|
||||
"source/ntp_time_unittest.cc",
|
||||
|
||||
@ -1,132 +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.
|
||||
*/
|
||||
|
||||
// This is a highly stripped-down version of libjingle's talk/base/logging.h.
|
||||
// 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.
|
||||
// The severity level passed as the first argument to the LOGging
|
||||
// functions is used as a filter, to limit the verbosity of the logging.
|
||||
// Static members of LogMessage documented below are used to control the
|
||||
// verbosity and target of the output.
|
||||
// There are several variations on the LOG macro which facilitate logging
|
||||
// of common error conditions, detailed below.
|
||||
|
||||
// LOG(sev) logs the given stream at severity "sev", which must be a
|
||||
// compile-time constant of the LoggingSeverity type, without the namespace
|
||||
// prefix.
|
||||
// LOG_V(sev) Like LOG(), but sev is a run-time variable of the LoggingSeverity
|
||||
// type (basically, it just doesn't prepend the namespace).
|
||||
// LOG_F(sev) Like LOG(), but includes the name of the current function.
|
||||
|
||||
#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_LOGGING_H_
|
||||
#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_LOGGING_H_
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Note that the non-standard LoggingSeverity aliases exist because they are
|
||||
// still in broad use. The meanings of the levels are:
|
||||
// LS_SENSITIVE: Information which should only be logged with the consent
|
||||
// of the user, due to privacy concerns.
|
||||
// LS_VERBOSE: This level is for data which we do not want to appear in the
|
||||
// normal debug log, but should appear in diagnostic logs.
|
||||
// LS_INFO: Chatty level used in debugging for all sorts of things, the default
|
||||
// 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
|
||||
};
|
||||
|
||||
class LogMessage {
|
||||
public:
|
||||
LogMessage(const char* file, int line, LoggingSeverity sev);
|
||||
~LogMessage();
|
||||
|
||||
static bool Loggable(LoggingSeverity sev);
|
||||
std::ostream& stream() { return print_stream_; }
|
||||
|
||||
private:
|
||||
// The ostream that buffers the formatted message before output
|
||||
std::ostringstream print_stream_;
|
||||
|
||||
// The severity level of this message
|
||||
LoggingSeverity severity_;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Macros which automatically disable logging when WEBRTC_LOGGING == 0
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LOG
|
||||
// The following non-obvious technique for implementation of a
|
||||
// conditional log stream was stolen from google3/base/logging.h.
|
||||
|
||||
// This class is used to explicitly ignore values in the conditional
|
||||
// logging macros. This avoids compiler warnings like "value computed
|
||||
// is not used" and "statement has no effect".
|
||||
|
||||
class LogMessageVoidify {
|
||||
public:
|
||||
LogMessageVoidify() { }
|
||||
// This has to be an operator with a precedence lower than << but
|
||||
// higher than ?:
|
||||
void operator&(std::ostream&) { }
|
||||
};
|
||||
|
||||
#if defined(WEBRTC_RESTRICT_LOGGING)
|
||||
// This should compile away logs matching the following condition.
|
||||
#define RESTRICT_LOGGING_PRECONDITION(sev) \
|
||||
sev < webrtc::LS_INFO ? (void) 0 :
|
||||
#else
|
||||
#define RESTRICT_LOGGING_PRECONDITION(sev)
|
||||
#endif
|
||||
|
||||
#define LOG_SEVERITY_PRECONDITION(sev) \
|
||||
RESTRICT_LOGGING_PRECONDITION(sev) !(webrtc::LogMessage::Loggable(sev)) \
|
||||
? (void) 0 \
|
||||
: webrtc::LogMessageVoidify() &
|
||||
|
||||
#define LOG(sev) \
|
||||
LOG_SEVERITY_PRECONDITION(webrtc::sev) \
|
||||
webrtc::LogMessage(__FILE__, __LINE__, webrtc::sev).stream()
|
||||
|
||||
// The _V version is for when a variable is passed in. It doesn't do the
|
||||
// namespace concatination.
|
||||
#define LOG_V(sev) \
|
||||
LOG_SEVERITY_PRECONDITION(sev) \
|
||||
webrtc::LogMessage(__FILE__, __LINE__, sev).stream()
|
||||
|
||||
// The _F version prefixes the message with the current function name.
|
||||
#if (defined(__GNUC__) && !defined(NDEBUG)) || defined(WANT_PRETTY_LOG_F)
|
||||
#define LOG_F(sev) LOG(sev) << __PRETTY_FUNCTION__ << ": "
|
||||
#else
|
||||
#define LOG_F(sev) LOG(sev) << __FUNCTION__ << ": "
|
||||
#endif
|
||||
|
||||
#endif // LOG
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_LOGGING_H_
|
||||
@ -13,7 +13,7 @@
|
||||
#include <android/log.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "webrtc/system_wrappers/include/logging.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -1,62 +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/include/logging.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/system_wrappers/include/trace.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
TraceLevel WebRtcSeverity(LoggingSeverity sev) {
|
||||
switch (sev) {
|
||||
// TODO(ajm): SENSITIVE doesn't have a corresponding webrtc level.
|
||||
case LS_SENSITIVE: 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;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the filename portion of the string (that following the last slash).
|
||||
const char* FilenameFromPath(const char* file) {
|
||||
const char* end1 = ::strrchr(file, '/');
|
||||
const char* end2 = ::strrchr(file, '\\');
|
||||
if (!end1 && !end2)
|
||||
return file;
|
||||
else
|
||||
return (end1 > end2) ? end1 + 1 : end2 + 1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
LogMessage::LogMessage(const char* file, int line, LoggingSeverity sev)
|
||||
: severity_(sev) {
|
||||
print_stream_ << "(" << FilenameFromPath(file) << ":" << line << "): ";
|
||||
}
|
||||
|
||||
bool LogMessage::Loggable(LoggingSeverity sev) {
|
||||
// |level_filter| is a bitmask, unlike libjingle's minimum severity value.
|
||||
return WebRtcSeverity(sev) & Trace::level_filter() ? true : false;
|
||||
}
|
||||
|
||||
LogMessage::~LogMessage() {
|
||||
const std::string& str = print_stream_.str();
|
||||
Trace::Add(WebRtcSeverity(severity_), kTraceUndefined, 0, "%s", str.c_str());
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -1,57 +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/include/logging.h"
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/event.h"
|
||||
#include "webrtc/system_wrappers/include/trace.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
const char kTestLogString[] = "Incredibly important test message!(?)";
|
||||
const int kTestLevel = kTraceWarning;
|
||||
|
||||
class LoggingTestCallback : public TraceCallback {
|
||||
public:
|
||||
LoggingTestCallback(rtc::Event* event) : event_(event) {}
|
||||
|
||||
private:
|
||||
void Print(TraceLevel level, const char* msg, int length) override {
|
||||
if (static_cast<size_t>(length) < arraysize(kTestLogString) ||
|
||||
level != kTestLevel) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string msg_str(msg, length);
|
||||
if (msg_str.find(kTestLogString) != std::string::npos)
|
||||
event_->Set();
|
||||
}
|
||||
|
||||
rtc::Event* const event_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(LoggingTest, LogStream) {
|
||||
Trace::CreateTrace();
|
||||
|
||||
rtc::Event event(false, false);
|
||||
LoggingTestCallback callback(&event);
|
||||
Trace::SetTraceCallback(&callback);
|
||||
|
||||
LOG(LS_WARNING) << kTestLogString;
|
||||
EXPECT_TRUE(event.Wait(2000));
|
||||
|
||||
Trace::SetTraceCallback(nullptr);
|
||||
Trace::ReturnTrace();
|
||||
}
|
||||
} // namespace webrtc
|
||||
Reference in New Issue
Block a user