Revert "Injectable logging"
This reverts commit 59216ec4a4151b1ba5478c8f2b5c9f01f4683d7f. Reason for revert: forces all logs to have identical tag Original change's description: > Injectable logging > > Allows passing a Loggable to PCFactory.initializationOptions, which > is then injected to Logging.java and logging.h. Future log messages > in both Java and native will then be passed to this Loggable. > > Bug: webrtc:9225 > Change-Id: I2ff693380639448301a78a93dc11d3a0106f0967 > Reviewed-on: https://webrtc-review.googlesource.com/73243 > Commit-Queue: Paulina Hensman <phensman@webrtc.org> > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> > Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#23241} TBR=magjed@webrtc.org,sakal@webrtc.org,kwiberg@webrtc.org,phensman@webrtc.org Change-Id: I27c9587238325b69b26166434740869021b7db8a No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:9225 Reviewed-on: https://webrtc-review.googlesource.com/76885 Reviewed-by: Alex Glaznev <glaznev@webrtc.org> Commit-Queue: Alex Glaznev <glaznev@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23253}
This commit is contained in:
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 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 "sdk/android/src/jni/logging/logsink.h"
|
||||
|
||||
#include "sdk/android/generated_logging_jni/jni/JNILogging_jni.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace jni {
|
||||
|
||||
JNILogSink::JNILogSink(JNIEnv* env, const JavaRef<jobject>& j_logging)
|
||||
: j_logging_(env, j_logging) {}
|
||||
JNILogSink::~JNILogSink() = default;
|
||||
|
||||
void JNILogSink::OnLogMessage(const std::string& msg,
|
||||
rtc::LoggingSeverity severity,
|
||||
const char* tag) {
|
||||
JNIEnv* env = AttachCurrentThreadIfNeeded();
|
||||
Java_JNILogging_logToInjectable(env, j_logging_, NativeToJavaString(env, msg),
|
||||
NativeToJavaInteger(env, severity),
|
||||
NativeToJavaString(env, tag));
|
||||
}
|
||||
|
||||
void JNILogSink::OnLogMessage(const std::string& msg) {
|
||||
RTC_NOTREACHED();
|
||||
}
|
||||
|
||||
} // namespace jni
|
||||
} // namespace webrtc
|
||||
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 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.
|
||||
*/
|
||||
#ifndef SDK_ANDROID_SRC_JNI_LOGGING_LOGSINK_H_
|
||||
#define SDK_ANDROID_SRC_JNI_LOGGING_LOGSINK_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "rtc_base/logging.h"
|
||||
#include "sdk/android/native_api/jni/java_types.h"
|
||||
#include "sdk/android/src/jni/jni_helpers.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace jni {
|
||||
|
||||
class JNILogSink : public rtc::LogSink {
|
||||
public:
|
||||
JNILogSink(JNIEnv* env, const JavaRef<jobject>& j_logging);
|
||||
~JNILogSink() override;
|
||||
|
||||
void OnLogMessage(const std::string& msg,
|
||||
rtc::LoggingSeverity severity,
|
||||
const char* tag) override;
|
||||
void OnLogMessage(const std::string& msg) override;
|
||||
|
||||
private:
|
||||
const ScopedJavaGlobalRef<jobject> j_logging_;
|
||||
};
|
||||
|
||||
} // namespace jni
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // SDK_ANDROID_SRC_JNI_LOGGING_LOGSINK_H_
|
||||
@ -17,6 +17,17 @@
|
||||
namespace webrtc {
|
||||
namespace jni {
|
||||
|
||||
JNI_FUNCTION_DECLARATION(void,
|
||||
Logging_nativeEnableLogToDebugOutput,
|
||||
JNIEnv* jni,
|
||||
jclass,
|
||||
jint nativeSeverity) {
|
||||
if (nativeSeverity >= rtc::LS_SENSITIVE && nativeSeverity <= rtc::LS_NONE) {
|
||||
rtc::LogMessage::LogToDebug(
|
||||
static_cast<rtc::LoggingSeverity>(nativeSeverity));
|
||||
}
|
||||
}
|
||||
|
||||
JNI_FUNCTION_DECLARATION(void,
|
||||
Logging_nativeEnableLogThreads,
|
||||
JNIEnv* jni,
|
||||
@ -31,5 +42,18 @@ JNI_FUNCTION_DECLARATION(void,
|
||||
rtc::LogMessage::LogTimestamps(true);
|
||||
}
|
||||
|
||||
JNI_FUNCTION_DECLARATION(void,
|
||||
Logging_nativeLog,
|
||||
JNIEnv* jni,
|
||||
jclass,
|
||||
jint j_severity,
|
||||
jstring j_tag,
|
||||
jstring j_message) {
|
||||
std::string message = JavaToStdString(jni, JavaParamRef<jstring>(j_message));
|
||||
std::string tag = JavaToStdString(jni, JavaParamRef<jstring>(j_tag));
|
||||
RTC_LOG_TAG(static_cast<rtc::LoggingSeverity>(j_severity), tag.c_str())
|
||||
<< message;
|
||||
}
|
||||
|
||||
} // namespace jni
|
||||
} // namespace webrtc
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 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 <memory>
|
||||
|
||||
#include "rtc_base/logging.h"
|
||||
#include "sdk/android/native_api/jni/java_types.h"
|
||||
#include "sdk/android/src/jni/jni_helpers.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace jni {
|
||||
|
||||
JNI_FUNCTION_DECLARATION(void,
|
||||
NativeLogger_nativeEnableLogToDebugOutput,
|
||||
JNIEnv* jni,
|
||||
jclass,
|
||||
jint native_severity) {
|
||||
// Check that native_severity is a valid enum.
|
||||
if (native_severity >= rtc::LS_SENSITIVE && native_severity <= rtc::LS_NONE) {
|
||||
rtc::LogMessage::LogToDebug(
|
||||
static_cast<rtc::LoggingSeverity>(native_severity));
|
||||
}
|
||||
}
|
||||
|
||||
JNI_FUNCTION_DECLARATION(void,
|
||||
NativeLogger_nativeLog,
|
||||
JNIEnv* jni,
|
||||
jclass,
|
||||
jint j_severity,
|
||||
jstring j_tag,
|
||||
jstring j_message) {
|
||||
std::string message = JavaToStdString(jni, JavaParamRef<jstring>(j_message));
|
||||
std::string tag = JavaToStdString(jni, JavaParamRef<jstring>(j_tag));
|
||||
RTC_LOG_TAG(static_cast<rtc::LoggingSeverity>(j_severity), tag.c_str())
|
||||
<< message;
|
||||
}
|
||||
|
||||
} // namespace jni
|
||||
} // namespace webrtc
|
||||
@ -27,7 +27,6 @@
|
||||
#include "sdk/android/generated_peerconnection_jni/jni/PeerConnectionFactory_jni.h"
|
||||
#include "sdk/android/native_api/jni/java_types.h"
|
||||
#include "sdk/android/src/jni/jni_helpers.h"
|
||||
#include "sdk/android/src/jni/logging/logsink.h"
|
||||
#include "sdk/android/src/jni/pc/androidnetworkmonitor.h"
|
||||
#include "sdk/android/src/jni/pc/audio.h"
|
||||
#include "sdk/android/src/jni/pc/icecandidate.h"
|
||||
@ -82,9 +81,6 @@ static char* field_trials_init_string = nullptr;
|
||||
static bool factory_static_initialized = false;
|
||||
static bool video_hw_acceleration_enabled = true;
|
||||
|
||||
// Set in PeerConnectionFactory_InjectLoggable().
|
||||
static std::unique_ptr<JNILogSink> jni_log_sink;
|
||||
|
||||
void PeerConnectionFactoryNetworkThreadReady() {
|
||||
RTC_LOG(LS_INFO) << "Network thread JavaCallback";
|
||||
JNIEnv* env = AttachCurrentThreadIfNeeded();
|
||||
@ -507,29 +503,5 @@ static jlong JNI_PeerConnectionFactory_GetNativePeerConnectionFactory(
|
||||
return jlongFromPointer(factoryFromJava(native_factory));
|
||||
}
|
||||
|
||||
static void JNI_PeerConnectionFactory_InjectLoggable(
|
||||
JNIEnv* jni,
|
||||
const JavaParamRef<jclass>&,
|
||||
const JavaParamRef<jobject>& j_logging,
|
||||
jint nativeSeverity) {
|
||||
// If there is already a LogSink, remove it from LogMessage.
|
||||
if (jni_log_sink) {
|
||||
rtc::LogMessage::RemoveLogToStream(jni_log_sink.get());
|
||||
}
|
||||
jni_log_sink = rtc::MakeUnique<JNILogSink>(jni, j_logging);
|
||||
rtc::LogMessage::AddLogToStream(
|
||||
jni_log_sink.get(), static_cast<rtc::LoggingSeverity>(nativeSeverity));
|
||||
rtc::LogMessage::LogToDebug(rtc::LS_NONE);
|
||||
}
|
||||
|
||||
static void JNI_PeerConnectionFactory_DeleteLoggable(
|
||||
JNIEnv* jni,
|
||||
const JavaParamRef<jclass>&) {
|
||||
if (jni_log_sink) {
|
||||
rtc::LogMessage::RemoveLogToStream(jni_log_sink.get());
|
||||
jni_log_sink.reset();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace jni
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user