diff --git a/webrtc/modules/audio_processing/aec3/render_delay_buffer.cc b/webrtc/modules/audio_processing/aec3/render_delay_buffer.cc index f012e00f29..f53a92519c 100644 --- a/webrtc/modules/audio_processing/aec3/render_delay_buffer.cc +++ b/webrtc/modules/audio_processing/aec3/render_delay_buffer.cc @@ -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 { diff --git a/webrtc/sdk/android/src/jni/androidmediadecoder_jni.cc b/webrtc/sdk/android/src/jni/androidmediadecoder_jni.cc index 8f50fc2107..e1e5b08349 100644 --- a/webrtc/sdk/android/src/jni/androidmediadecoder_jni.cc +++ b/webrtc/sdk/android/src/jni/androidmediadecoder_jni.cc @@ -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; diff --git a/webrtc/sdk/android/src/jni/androidmediaencoder_jni.cc b/webrtc/sdk/android/src/jni/androidmediaencoder_jni.cc index 1274b8e47f..44acccf630 100644 --- a/webrtc/sdk/android/src/jni/androidmediaencoder_jni.cc +++ b/webrtc/sdk/android/src/jni/androidmediaencoder_jni.cc @@ -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; diff --git a/webrtc/system_wrappers/BUILD.gn b/webrtc/system_wrappers/BUILD.gn index 708fd318f0..bbb1b12ba3 100644 --- a/webrtc/system_wrappers/BUILD.gn +++ b/webrtc/system_wrappers/BUILD.gn @@ -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", diff --git a/webrtc/system_wrappers/include/logging.h b/webrtc/system_wrappers/include/logging.h deleted file mode 100644 index 0089841d4e..0000000000 --- a/webrtc/system_wrappers/include/logging.h +++ /dev/null @@ -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 - -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_ diff --git a/webrtc/system_wrappers/source/logcat_trace_context.cc b/webrtc/system_wrappers/source/logcat_trace_context.cc index cc2e45b28e..3771be59d9 100644 --- a/webrtc/system_wrappers/source/logcat_trace_context.cc +++ b/webrtc/system_wrappers/source/logcat_trace_context.cc @@ -13,7 +13,7 @@ #include #include -#include "webrtc/system_wrappers/include/logging.h" +#include "webrtc/base/logging.h" namespace webrtc { diff --git a/webrtc/system_wrappers/source/logging.cc b/webrtc/system_wrappers/source/logging.cc deleted file mode 100644 index 6b50d6acf8..0000000000 --- a/webrtc/system_wrappers/source/logging.cc +++ /dev/null @@ -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 - -#include - -#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 diff --git a/webrtc/system_wrappers/source/logging_unittest.cc b/webrtc/system_wrappers/source/logging_unittest.cc deleted file mode 100644 index 6be4da10e1..0000000000 --- a/webrtc/system_wrappers/source/logging_unittest.cc +++ /dev/null @@ -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(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