Melon 1 жил өмнө
parent
commit
17d61c6c29

+ 24 - 6
app/src/main/java/vinno/sportinspect/utils/LogUtil.java

@@ -1,24 +1,42 @@
 package vinno.sportinspect.utils;
 
 
+import static com.orhanobut.logger.Logger.DEBUG;
+
+import androidx.annotation.Nullable;
+
 import com.orhanobut.logger.AndroidLogAdapter;
+import com.orhanobut.logger.DiskLogAdapter;
 import com.orhanobut.logger.FormatStrategy;
 import com.orhanobut.logger.Logger;
 import com.orhanobut.logger.PrettyFormatStrategy;
 
 public class LogUtil {
 
-    public static void init(boolean isLogEnable) {
+    public static void init(boolean isDebug) {
         FormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder()
                 .showThreadInfo(false)
                 .methodCount(0)
                 .methodOffset(7)
-                .tag("LogUtil")
+                .tag("VinnoVnoteSdk")
                 .build();
-        Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy) {
+
+        if (isDebug) {
+            Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy){
+                @Override
+                public boolean isLoggable(int priority, @Nullable String tag) {
+                    return true;
+                }
+            });
+        }
+
+        Logger.addLogAdapter(new DiskLogAdapter(formatStrategy) {
             @Override
-            public boolean isLoggable(int priority, String tag) {
-                return isLogEnable;
+            public boolean isLoggable(int priority, @Nullable String tag) {
+                if(isDebug){
+                    return  true;
+                }
+                return priority > DEBUG;
             }
         });
     }
@@ -29,7 +47,7 @@ public class LogUtil {
 
     public static void d(String message) {
         if (message != null) {
-            Logger.d("vinno===>"+message);
+            Logger.d("vinno===>" + message);
         } else {
             Logger.e("vinno===>printer null");
         }