package com.genymobile.scrcpy;

import android.util.Log;

/**
 * Log both to Android logger (so that logs are visible in "adb logcat") and standard output/error (so that they are visible in the terminal
 * directly).
 */
public final class Ln {

    private static final String TAG = "scrcpy";

    private Ln() {
        // not instantiable
    }

    public static void d(String message) {
        Log.d(TAG, message);
        System.out.println("DEBUG: " + message);
    }

    public static void i(String message) {
        Log.i(TAG, message);
        System.out.println("INFO: " + message);
    }

    public static void w(String message) {
        Log.w(TAG, message);
        System.out.println("WARN: " + message);
    }

    public static void e(String message, Throwable throwable) {
        Log.e(TAG, message, throwable);
        System.out.println("ERROR: " + message);
        throwable.printStackTrace();
    }
}

@@ -296,101 +296,428 @@
     
-private Ln() %7B%0A        // not instantiable%0A    %7D%0A%0A    public static void d(String message) %7B%0A
+enum Level %7B%0A        DEBUG,%0A        INFO,%0A        WARN,%0A        ERROR;%0A    %7D%0A%0A    private static final Level THRESHOLD = BuildConfig.DEBUG ? Level.DEBUG : Level.INFO;%0A%0A    private Ln() %7B%0A        // not instantiable%0A    %7D%0A%0A    public static boolean isEnabled(Level level) %7B%0A        return level.ordinal() %3E= THRESHOLD.ordinal();%0A    %7D%0A%0A    public static void d(String message) %7B%0A        if (isEnabled(Level.DEBUG)) %7B%0A    
     
@@ -733,32 +733,36 @@
 (TAG, message);%0A
+    
         System.o
@@ -786,32 +786,42 @@
 : %22 + message);%0A
+        %7D%0A
     %7D%0A%0A    publi
@@ -846,32 +846,73 @@
 ring message) %7B%0A
+        if (isEnabled(Level.INFO)) %7B%0A    
         Log.i(TA
@@ -924,32 +924,36 @@
 ssage);%0A        
+  
+  
 System.out.print
@@ -968,32 +968,42 @@
 : %22 + message);%0A
+        %7D%0A
     %7D%0A%0A    publi
@@ -1028,32 +1028,73 @@
 ring message) %7B%0A
+        if (isEnabled(Level.WARN)) %7B%0A    
         Log.w(TA
@@ -1098,32 +1098,36 @@
 (TAG, message);%0A
+    
         System.o
@@ -1154,24 +1154,34 @@
 + message);%0A
+        %7D%0A
     %7D%0A%0A    p
@@ -1235,24 +1235,66 @@
 hrowable) %7B%0A
+        if (isEnabled(Level.ERROR)) %7B%0A    
         Log.
@@ -1321,32 +1321,36 @@
 wable);%0A        
+   
+ 
 System.out.print
@@ -1382,16 +1382,20 @@
         
+    
 throwabl
@@ -1411,20 +1411,30 @@
 ackTrace();%0A
+        %7D%0A
     %7D%0A%7D%0A

Enable debug logs only for debug builds on server