195 lines
6 KiB
Java
195 lines
6 KiB
Java
package org.webrtc;
|
|
|
|
import androidx.annotation.Nullable;
|
|
import java.io.PrintWriter;
|
|
import java.io.StringWriter;
|
|
import java.util.EnumSet;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
/* loaded from: classes3.dex */
|
|
public class Logging {
|
|
@Nullable
|
|
public static ExternalReporter externalReporter;
|
|
private static final Logger fallbackLogger = createFallbackLogger();
|
|
@Nullable
|
|
private static Loggable loggable;
|
|
private static Severity loggableSeverity;
|
|
private static volatile boolean loggingEnabled;
|
|
|
|
/* renamed from: org.webrtc.Logging$1 reason: invalid class name */
|
|
/* loaded from: classes3.dex */
|
|
public static /* synthetic */ class AnonymousClass1 {
|
|
public static final /* synthetic */ int[] $SwitchMap$org$webrtc$Logging$Severity;
|
|
|
|
static {
|
|
Severity.values();
|
|
int[] iArr = new int[5];
|
|
$SwitchMap$org$webrtc$Logging$Severity = iArr;
|
|
try {
|
|
iArr[Severity.LS_ERROR.ordinal()] = 1;
|
|
} catch (NoSuchFieldError unused) {
|
|
}
|
|
try {
|
|
$SwitchMap$org$webrtc$Logging$Severity[Severity.LS_WARNING.ordinal()] = 2;
|
|
} catch (NoSuchFieldError unused2) {
|
|
}
|
|
try {
|
|
$SwitchMap$org$webrtc$Logging$Severity[Severity.LS_INFO.ordinal()] = 3;
|
|
} catch (NoSuchFieldError unused3) {
|
|
}
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes3.dex */
|
|
public interface ExternalReporter {
|
|
void e(String str, String str2, Throwable th);
|
|
}
|
|
|
|
/* loaded from: classes3.dex */
|
|
public enum Severity {
|
|
LS_VERBOSE,
|
|
LS_INFO,
|
|
LS_WARNING,
|
|
LS_ERROR,
|
|
LS_NONE
|
|
}
|
|
|
|
@Deprecated
|
|
/* loaded from: classes3.dex */
|
|
public enum TraceLevel {
|
|
TRACE_NONE(0),
|
|
TRACE_STATEINFO(1),
|
|
TRACE_WARNING(2),
|
|
TRACE_ERROR(4),
|
|
TRACE_CRITICAL(8),
|
|
TRACE_APICALL(16),
|
|
TRACE_DEFAULT(255),
|
|
TRACE_MODULECALL(32),
|
|
TRACE_MEMORY(256),
|
|
TRACE_TIMER(512),
|
|
TRACE_STREAM(1024),
|
|
TRACE_DEBUG(2048),
|
|
TRACE_INFO(4096),
|
|
TRACE_TERSEINFO(8192),
|
|
TRACE_ALL(65535);
|
|
|
|
public final int level;
|
|
|
|
TraceLevel(int i) {
|
|
this.level = i;
|
|
}
|
|
}
|
|
|
|
private static Logger createFallbackLogger() {
|
|
Logger logger = Logger.getLogger("org.webrtc.Logging");
|
|
logger.setLevel(Level.ALL);
|
|
return logger;
|
|
}
|
|
|
|
public static void d(String str, String str2) {
|
|
log(Severity.LS_INFO, str, str2);
|
|
}
|
|
|
|
public static void deleteInjectedLoggable() {
|
|
loggable = null;
|
|
}
|
|
|
|
public static void e(String str, String str2) {
|
|
log(Severity.LS_ERROR, str, str2);
|
|
ExternalReporter externalReporter2 = externalReporter;
|
|
if (externalReporter2 != null) {
|
|
externalReporter2.e(str, str2, null);
|
|
}
|
|
}
|
|
|
|
public static void e(String str, String str2, Throwable th) {
|
|
Severity severity = Severity.LS_ERROR;
|
|
log(severity, str, str2);
|
|
log(severity, str, th.toString());
|
|
log(severity, str, getStackTraceString(th));
|
|
ExternalReporter externalReporter2 = externalReporter;
|
|
if (externalReporter2 != null) {
|
|
externalReporter2.e(str, str2, th);
|
|
}
|
|
}
|
|
|
|
public static void enableLogThreads() {
|
|
nativeEnableLogThreads();
|
|
}
|
|
|
|
public static void enableLogTimeStamps() {
|
|
nativeEnableLogTimeStamps();
|
|
}
|
|
|
|
public static synchronized void enableLogToDebugOutput(Severity severity) {
|
|
synchronized (Logging.class) {
|
|
if (loggable == null) {
|
|
nativeEnableLogToDebugOutput(severity.ordinal());
|
|
loggingEnabled = true;
|
|
} else {
|
|
throw new IllegalStateException("Logging to native debug output not supported while Loggable is injected. Delete the Loggable before calling this method.");
|
|
}
|
|
}
|
|
}
|
|
|
|
@Deprecated
|
|
public static void enableTracing(String str, EnumSet<TraceLevel> enumSet) {
|
|
}
|
|
|
|
private static String getStackTraceString(Throwable th) {
|
|
if (th == null) {
|
|
return "";
|
|
}
|
|
StringWriter stringWriter = new StringWriter();
|
|
th.printStackTrace(new PrintWriter(stringWriter));
|
|
return stringWriter.toString();
|
|
}
|
|
|
|
public static void injectLoggable(Loggable loggable2, Severity severity) {
|
|
if (loggable2 != null) {
|
|
loggable = loggable2;
|
|
loggableSeverity = severity;
|
|
}
|
|
}
|
|
|
|
public static void log(Severity severity, String str, String str2) {
|
|
if (str == null || str2 == null) {
|
|
throw new IllegalArgumentException("Logging tag or message may not be null.");
|
|
} else if (loggable != null) {
|
|
if (severity.ordinal() >= loggableSeverity.ordinal()) {
|
|
loggable.onLogMessage(str2, severity, str);
|
|
}
|
|
} else if (loggingEnabled) {
|
|
nativeLog(severity.ordinal(), str, str2);
|
|
} else {
|
|
int ordinal = severity.ordinal();
|
|
Level level = ordinal != 1 ? ordinal != 2 ? ordinal != 3 ? Level.FINE : Level.SEVERE : Level.WARNING : Level.INFO;
|
|
Logger logger = fallbackLogger;
|
|
logger.log(level, str + ": " + str2);
|
|
}
|
|
}
|
|
|
|
private static native void nativeEnableLogThreads();
|
|
|
|
private static native void nativeEnableLogTimeStamps();
|
|
|
|
private static native void nativeEnableLogToDebugOutput(int i);
|
|
|
|
private static native void nativeLog(int i, String str, String str2);
|
|
|
|
public static void v(String str, String str2) {
|
|
log(Severity.LS_VERBOSE, str, str2);
|
|
}
|
|
|
|
public static void w(String str, String str2) {
|
|
log(Severity.LS_WARNING, str, str2);
|
|
}
|
|
|
|
public static void w(String str, String str2, Throwable th) {
|
|
Severity severity = Severity.LS_WARNING;
|
|
log(severity, str, str2);
|
|
log(severity, str, th.toString());
|
|
log(severity, str, getStackTraceString(th));
|
|
}
|
|
}
|