From 27879c3f0131407771e2b33825ba631d54c41d79 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Wed, 31 May 2017 17:43:55 +0800 Subject: [PATCH] Improve Logger --- .../com/topjohnwu/magisk/utils/Logger.java | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/Logger.java b/app/src/main/java/com/topjohnwu/magisk/utils/Logger.java index 623693eee..51ad587aa 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/Logger.java +++ b/app/src/main/java/com/topjohnwu/magisk/utils/Logger.java @@ -4,37 +4,30 @@ import android.util.Log; import com.topjohnwu.magisk.MagiskManager; +import java.util.Locale; + public class Logger { - public static final String TAG = "Magisk"; + public static final String MAIN_TAG = "Magisk"; + public static final String DEBUG_TAG = "MagiskManager"; - public static void debug(String msg) { - Log.d(TAG, "DEBUG: " + msg); + public static void debug(String fmt, Object... args) { + Log.d(DEBUG_TAG, "DEBUG: " + String.format(Locale.US, fmt, args)); } - public static void error(String msg) { - Log.e(TAG, "MANAGERERROR: " + msg); + public static void error(String fmt, Object... args) { + Log.e(MAIN_TAG, "MANAGERERROR: " + String.format(Locale.US, fmt, args)); } - public static void dev(String msg, Object... args) { + public static void dev(String fmt, Object... args) { if (MagiskManager.devLogging) { - if (args.length == 1 && args[0] instanceof Throwable) { - Log.d(TAG, "MANAGER: " + msg, (Throwable) args[0]); - } else { - Log.d(TAG, "MANAGER: " + String.format(msg, args)); - } + Log.d(DEBUG_TAG, String.format(Locale.US, fmt, args)); } } - public static void dev(String msg) { - if (MagiskManager.devLogging) { - Log.d(TAG, "MANAGER: " + msg); - } - } - - public static void shell(boolean root, String msg) { + public static void shell(boolean root, String fmt, Object... args) { if (MagiskManager.shellLogging) { - Log.d(TAG, (root ? "MANAGERSU " : "MANAGERSH ") + msg); + Log.d(DEBUG_TAG, (root ? "MANAGERSU: " : "MANAGERSH: ") + String.format(Locale.US, fmt, args)); } } }