Reland "Reland "Injectable logging""
This is a reland of 21219a0e43446701810236fb9fdd59be072c12df The default implementation of OnLogMessage(msg, sev, tag) discarded the tag, resulting in FileRotatingLogSink not receiving tags. Since the revert the default implementation of OnLogMessage(msg, sev, tag) has been updated to add the tag to the log message. A more efficient implementation of it has also been added for FileRotatingLogSink. Unit tests are added for the default implementation and for Loggable injection. Original change's description: > 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} Bug: webrtc:9225 Change-Id: I67a5728fe772f0bedc9509713ed8b8ffdc31af81 TBR: kwiberg Reviewed-on: https://webrtc-review.googlesource.com/80860 Commit-Queue: Paulina Hensman <phensman@webrtc.org> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23711}
This commit is contained in:

committed by
Commit Bot

parent
6f440ed5b5
commit
1ec04f19c6
@ -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;
|
||||
|
||||
@ -42,16 +43,21 @@ public class PeerConnectionFactory {
|
||||
final boolean enableVideoHwAcceleration;
|
||||
final NativeLibraryLoader nativeLibraryLoader;
|
||||
final String nativeLibraryName;
|
||||
@Nullable Loggable loggable;
|
||||
@Nullable Severity loggableSeverity;
|
||||
|
||||
private InitializationOptions(Context applicationContext, String fieldTrials,
|
||||
boolean enableInternalTracer, boolean enableVideoHwAcceleration,
|
||||
NativeLibraryLoader nativeLibraryLoader, String nativeLibraryName) {
|
||||
NativeLibraryLoader nativeLibraryLoader, String nativeLibraryName,
|
||||
@Nullable Loggable loggable, @Nullable Severity loggableSeverity) {
|
||||
this.applicationContext = applicationContext;
|
||||
this.fieldTrials = fieldTrials;
|
||||
this.enableInternalTracer = enableInternalTracer;
|
||||
this.enableVideoHwAcceleration = enableVideoHwAcceleration;
|
||||
this.nativeLibraryLoader = nativeLibraryLoader;
|
||||
this.nativeLibraryName = nativeLibraryName;
|
||||
this.loggable = loggable;
|
||||
this.loggableSeverity = loggableSeverity;
|
||||
}
|
||||
|
||||
public static Builder builder(Context applicationContext) {
|
||||
@ -65,6 +71,8 @@ public class PeerConnectionFactory {
|
||||
private boolean enableVideoHwAcceleration = true;
|
||||
private NativeLibraryLoader nativeLibraryLoader = new NativeLibrary.DefaultLoader();
|
||||
private String nativeLibraryName = "jingle_peerconnection_so";
|
||||
@Nullable private Loggable loggable = null;
|
||||
@Nullable private Severity loggableSeverity = null;
|
||||
|
||||
Builder(Context applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
@ -89,15 +97,22 @@ public class PeerConnectionFactory {
|
||||
this.nativeLibraryLoader = nativeLibraryLoader;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setNativeLibraryName(String nativeLibraryName) {
|
||||
this.nativeLibraryName = nativeLibraryName;
|
||||
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,
|
||||
nativeLibraryName);
|
||||
enableInternalTracer, enableVideoHwAcceleration, nativeLibraryLoader, nativeLibraryName,
|
||||
loggable, loggableSeverity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -207,6 +222,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() {
|
||||
@ -482,4 +507,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