package com.amplifyframework.logging;

import android.annotation.SuppressLint;
import android.util.Log;
import java.util.Objects;

/* loaded from: classes4.dex */
final class AndroidLogger implements Logger {
    private static boolean isEnabled = true;
    private final String namespace;
    private final LogLevel threshold;

    /* JADX INFO: Access modifiers changed from: package-private */
    public AndroidLogger(String str, LogLevel logLevel) {
        Objects.requireNonNull(logLevel);
        this.threshold = logLevel;
        Objects.requireNonNull(str);
        this.namespace = str;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static void setIsEnabled(boolean z10) {
        isEnabled = z10;
    }

    private boolean shouldNotLogMessage(LogLevel logLevel) {
        return !isEnabled || this.threshold.above(logLevel);
    }

    @Override // com.amplifyframework.logging.Logger
    @SuppressLint({"LogConditional"})
    public void debug(String str) {
        if (shouldNotLogMessage(LogLevel.DEBUG)) {
            return;
        }
        Log.d(this.namespace, String.valueOf(str));
    }

    @Override // com.amplifyframework.logging.Logger
    public void error(String str) {
        if (shouldNotLogMessage(LogLevel.ERROR)) {
            return;
        }
        Log.e(this.namespace, String.valueOf(str));
    }

    @Override // com.amplifyframework.logging.Logger
    public String getNamespace() {
        return this.namespace;
    }

    @Override // com.amplifyframework.logging.Logger
    public LogLevel getThresholdLevel() {
        return this.threshold;
    }

    @Override // com.amplifyframework.logging.Logger
    @SuppressLint({"LogConditional"})
    public void info(String str) {
        if (shouldNotLogMessage(LogLevel.INFO)) {
            return;
        }
        Log.i(this.namespace, String.valueOf(str));
    }

    @Override // com.amplifyframework.logging.Logger
    @SuppressLint({"LogConditional"})
    public void verbose(String str) {
        if (shouldNotLogMessage(LogLevel.VERBOSE)) {
            return;
        }
        Log.v(this.namespace, String.valueOf(str));
    }

    @Override // com.amplifyframework.logging.Logger
    public void warn(String str) {
        if (shouldNotLogMessage(LogLevel.WARN)) {
            return;
        }
        Log.w(this.namespace, String.valueOf(str));
    }

    @Override // com.amplifyframework.logging.Logger
    public void error(String str, Throwable th2) {
        if (shouldNotLogMessage(LogLevel.ERROR)) {
            return;
        }
        Log.e(this.namespace, str, th2);
    }

    @Override // com.amplifyframework.logging.Logger
    public void warn(String str, Throwable th2) {
        if (shouldNotLogMessage(LogLevel.WARN)) {
            return;
        }
        Log.w(this.namespace, str, th2);
    }
}
