mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 11:57:39 +00:00
Improve Logger
This commit is contained in:
parent
29096eb5d7
commit
27879c3f01
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user