package d.h.a;

import d.f.a.r2.h3;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/* JADX INFO: compiled from: LoggerPrinter.java */
/* JADX INFO: loaded from: classes.dex */
public class f {
    public final ThreadLocal<String> a = new ThreadLocal<>();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final List<c> f3581b = new ArrayList();

    public void a(Object obj) {
        c(3, null, obj == null ? "null" : !obj.getClass().isArray() ? obj.toString() : obj instanceof boolean[] ? Arrays.toString((boolean[]) obj) : obj instanceof byte[] ? Arrays.toString((byte[]) obj) : obj instanceof char[] ? Arrays.toString((char[]) obj) : obj instanceof short[] ? Arrays.toString((short[]) obj) : obj instanceof int[] ? Arrays.toString((int[]) obj) : obj instanceof long[] ? Arrays.toString((long[]) obj) : obj instanceof float[] ? Arrays.toString((float[]) obj) : obj instanceof double[] ? Arrays.toString((double[]) obj) : obj instanceof Object[] ? Arrays.deepToString((Object[]) obj) : "Couldn't find a correct type for the object", new Object[0]);
    }

    public synchronized void b(int i2, String str, String str2, Throwable th) {
        if (th != null && str2 != null) {
            try {
                str2 = str2 + " : " + h3.n(th);
            } catch (Throwable th2) {
                throw th2;
            }
        }
        if (th != null && str2 == null) {
            str2 = h3.n(th);
        }
        if (str2 == null || str2.length() == 0) {
            str2 = "Empty/NULL log message";
        }
        for (c cVar : this.f3581b) {
            if (cVar.b(i2, str)) {
                cVar.a(i2, str, str2);
            }
        }
    }

    public final synchronized void c(int i2, Throwable th, String str, Object... objArr) {
        Objects.requireNonNull(str);
        String str2 = this.a.get();
        if (str2 != null) {
            this.a.remove();
        } else {
            str2 = null;
        }
        if (objArr != null && objArr.length != 0) {
            str = String.format(str, objArr);
        }
        b(i2, str2, str, null);
    }
}
