package g.h.a;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

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

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

    public void a(@NonNull String str, @Nullable Object... objArr) {
        d(3, null, str, objArr);
    }

    public void b(@NonNull String str, @Nullable Object... objArr) {
        d(6, null, str, objArr);
    }

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

    public final synchronized void d(int i2, @Nullable Throwable th, @NonNull String str, @Nullable 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);
        }
        c(i2, str2, str, th);
    }
}
