content: package okhttp3.internal.platform.android;
  
  import android.util.Log;
  import java.util.LinkedHashMap;
  import java.util.Map;
  import java.util.concurrent.CopyOnWriteArraySet;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import kotlin.Metadata;
  import kotlin.collections.MapsKt;
  import kotlin.jvm.internal.Intrinsics;
  import kotlin.text.StringsKt;
  import mt.Log1F380D;
  import okhttp3.OkHttpClient;
  import okhttp3.internal.concurrent.TaskRunner;
  import okhttp3.internal.http2.Http2;
  
  @Metadata(bv = {1, 0, 3}, d1 = {"\u00006\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010$\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0004\n\u0002\u0010\u0003\n\u0002\b\u0007\bÇ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J/\u0010\u000b\u001a\u00020\f2\u0006\u0010\r\u001a\u00020\n2\u0006\u0010\u000e\u001a\u00020\u00042\u0006\u0010\u000f\u001a\u00020\n2\b\u0010\u0010\u001a\u0004\u0018\u00010\u0011H\u0000¢\u0006\u0002\b\u0012J\u0006\u0010\u0013\u001a\u00020\fJ\u0018\u0010\u0014\u001a\u00020\f2\u0006\u0010\u0015\u001a\u00020\n2\u0006\u0010\u0016\u001a\u00020\nH\u0002J\u0010\u0010\u0017\u001a\u00020\n2\u0006\u0010\r\u001a\u00020\nH\u0002R\u000e\u0010\u0003\u001a\u00020\u0004XT¢\u0006\u0002\n\u0000R\u0014\u0010\u0005\u001a\b\u0012\u0004\u0012\u00020\u00070\u0006X\u0004¢\u0006\u0002\n\u0000R\u001a\u0010\b\u001a\u000e\u0012\u0004\u0012\u00020\n\u0012\u0004\u0012\u00020\n0\tX\u0004¢\u0006\u0002\n\u0000¨\u0006\u0018"}, d2 = {"Lokhttp3/internal/platform/android/AndroidLog;", "", "()V", "MAX_LOG_LENGTH", "", "configuredLoggers", "Ljava/util/concurrent/CopyOnWriteArraySet;", "Ljava/util/logging/Logger;", "knownLoggers", "", "", "androidLog", "", "loggerName", "logLevel", "message", "t", "", "androidLog$okhttp", "enable", "enableLogging", "logger", "tag", "loggerTag", "okhttp"}, k = 1, mv = {1, 4, 0})
  /* compiled from: 01DE */
  public final class AndroidLog {
      public static final AndroidLog INSTANCE = new AndroidLog();
      private static final int MAX_LOG_LENGTH = 4000;
      private static final CopyOnWriteArraySet<Logger> configuredLoggers = new CopyOnWriteArraySet<>();
      private static final Map<String, String> knownLoggers;
  
      static {
          LinkedHashMap linkedHashMap = new LinkedHashMap();
          LinkedHashMap linkedHashMap2 = linkedHashMap;
          Package packageR = OkHttpClient.class.getPackage();
          String name = packageR != null ? packageR.getName() : null;
          if (name != null) {
              linkedHashMap2.put(name, "OkHttp");
          }
          String name2 = OkHttpClient.class.getName();
          Intrinsics.checkNotNullExpressionValue(name2, "OkHttpClient::class.java.name");
          linkedHashMap2.put(name2, "okhttp.OkHttpClient");
          String name3 = Http2.class.getName();
          Intrinsics.checkNotNullExpressionValue(name3, "Http2::class.java.name");
          linkedHashMap2.put(name3, "okhttp.Http2");
          String name4 = TaskRunner.class.getName();
          Intrinsics.checkNotNullExpressionValue(name4, "TaskRunner::class.java.name");
          linkedHashMap2.put(name4, "okhttp.TaskRunner");
          linkedHashMap2.put("okhttp3.mockwebserver.MockWebServer", "okhttp.MockWebServer");
          knownLoggers = MapsKt.toMap(linkedHashMap);
      }
  
      private AndroidLog() {
      }
  
      private final void enableLogging(String logger, String tag) {
          Logger logger2 = Logger.getLogger(logger);
          if (configuredLoggers.add(logger2)) {
              Intrinsics.checkNotNullExpressionValue(logger2, "logger");
              logger2.setUseParentHandlers(false);
              logger2.setLevel(Log.isLoggable(tag, 3) ? Level.FINE : Log.isLoggable(tag, 4) ? Level.INFO : Level.WARNING);
              logger2.addHandler(AndroidLogHandler.INSTANCE);
          }
      }
  
      private final String loggerTag(String loggerName) {
          String str = knownLoggers.get(loggerName);
          if (str != null) {
              return str;
          }
          String take = StringsKt.take(loggerName, 23);
          Log1F380D.a((Object) take);
          return take;
      }
  
      public final void enable() {
          for (Map.Entry next : knownLoggers.entrySet()) {
              enableLogging((String) next.getKey(), (String) next.getValue());
          }
      }
  
      public final void androidLog$okhttp(String loggerName, int logLevel, String message, Throwable t) {
          Intrinsics.checkNotNullParameter(loggerName, "loggerName");
          Intrinsics.checkNotNullParameter(message, "message");
          String loggerTag = loggerTag(loggerName);
          if (Log.isLoggable(loggerTag, logLevel)) {
              String str = message;
              if (t != null) {
                  StringBuilder append = new StringBuilder().append(str).append("\n");
                  String stackTraceString = Log.getStackTraceString(t);
                  Log1F380D.a((Object) stackTraceString);
                  str = append.append(stackTraceString).toString();
              }
              int i = 0;
              int length = str.length();
              while (i < length) {
                  int indexOf$default = StringsKt.indexOf$default((CharSequence) str, 10, i, false, 4, (Object) null);
                  int i2 = indexOf$default != -1 ? indexOf$default : length;
                  do {
                      int min = Math.min(i2, i + MAX_LOG_LENGTH);
                      if (str != null) {
                          String substring = str.substring(i, min);
                          Intrinsics.checkNotNullExpressionValue(substring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
                          Log.println(logLevel, loggerTag, substring);
                          i = min;
                      } else {
                          throw new NullPointerException("null cannot be cast to non-null type java.lang.String");
                      }
                  } while (i < i2);
                  i++;
              }
          }
      }
  }
  