Reland "Injectable logging"
Any injected loggable or NativeLogger would be deleted if PCFactory was reinitialized without calling setInjectableLogger. Now native logging is not implemented as a Loggable, so it will remain active unless a Loggable is injected. This is a reland of 59216ec4a4151b1ba5478c8f2b5c9f01f4683d7f 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} Bug: webrtc:9225 Change-Id: I2fe3fbc8c323814284bb62e43fe1870bdab581ee TBR: kwiberg Reviewed-on: https://webrtc-review.googlesource.com/77140 Commit-Queue: Paulina Hensman <phensman@webrtc.org> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23310}
This commit is contained in:
committed by
Commit Bot
parent
812ceafb5a
commit
21219a0e43
@ -13,6 +13,7 @@ package org.webrtc;
|
||||
import android.content.Context;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import org.webrtc.Logging.Severity;
|
||||
import org.webrtc.audio.AudioDeviceModule;
|
||||
import org.webrtc.audio.LegacyAudioDeviceModule;
|
||||
|
||||
@ -41,15 +42,20 @@ public class PeerConnectionFactory {
|
||||
final boolean enableInternalTracer;
|
||||
final boolean enableVideoHwAcceleration;
|
||||
final NativeLibraryLoader nativeLibraryLoader;
|
||||
@Nullable Loggable loggable;
|
||||
@Nullable Severity loggableSeverity;
|
||||
|
||||
private InitializationOptions(Context applicationContext, String fieldTrials,
|
||||
boolean enableInternalTracer, boolean enableVideoHwAcceleration,
|
||||
NativeLibraryLoader nativeLibraryLoader) {
|
||||
NativeLibraryLoader nativeLibraryLoader, @Nullable Loggable loggable,
|
||||
@Nullable Severity loggableSeverity) {
|
||||
this.applicationContext = applicationContext;
|
||||
this.fieldTrials = fieldTrials;
|
||||
this.enableInternalTracer = enableInternalTracer;
|
||||
this.enableVideoHwAcceleration = enableVideoHwAcceleration;
|
||||
this.nativeLibraryLoader = nativeLibraryLoader;
|
||||
this.loggable = loggable;
|
||||
this.loggableSeverity = loggableSeverity;
|
||||
}
|
||||
|
||||
public static Builder builder(Context applicationContext) {
|
||||
@ -62,6 +68,8 @@ public class PeerConnectionFactory {
|
||||
private boolean enableInternalTracer = false;
|
||||
private boolean enableVideoHwAcceleration = true;
|
||||
private NativeLibraryLoader nativeLibraryLoader = new NativeLibrary.DefaultLoader();
|
||||
@Nullable private Loggable loggable = null;
|
||||
@Nullable private Severity loggableSeverity = null;
|
||||
|
||||
Builder(Context applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
@ -87,9 +95,16 @@ public class PeerConnectionFactory {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setInjectableLogger(Loggable loggable, Severity severity) {
|
||||
this.loggable = loggable;
|
||||
this.loggableSeverity = severity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PeerConnectionFactory.InitializationOptions createInitializationOptions() {
|
||||
return new PeerConnectionFactory.InitializationOptions(applicationContext, fieldTrials,
|
||||
enableInternalTracer, enableVideoHwAcceleration, nativeLibraryLoader);
|
||||
enableInternalTracer, enableVideoHwAcceleration, nativeLibraryLoader, loggable,
|
||||
loggableSeverity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -199,6 +214,16 @@ public class PeerConnectionFactory {
|
||||
if (options.enableInternalTracer && !internalTracerInitialized) {
|
||||
initializeInternalTracer();
|
||||
}
|
||||
if (options.loggable != null) {
|
||||
Logging.injectLoggable(options.loggable, options.loggableSeverity);
|
||||
nativeInjectLoggable(new JNILogging(options.loggable), options.loggableSeverity.ordinal());
|
||||
} else {
|
||||
Logging.d(TAG,
|
||||
"PeerConnectionFactory was initialized without an injected Loggable. "
|
||||
+ "Any existing Loggable will be deleted.");
|
||||
Logging.deleteInjectedLoggable();
|
||||
nativeDeleteLoggable();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkInitializeHasBeenCalled() {
|
||||
@ -474,4 +499,6 @@ public class PeerConnectionFactory {
|
||||
private static native void nativeInvokeThreadsCallbacks(long factory);
|
||||
private static native void nativeFreeFactory(long factory);
|
||||
private static native long nativeGetNativePeerConnectionFactory(long factory);
|
||||
private static native void nativeInjectLoggable(JNILogging jniLogging, int severity);
|
||||
private static native void nativeDeleteLoggable();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user