public class Logger extends Object
Log. To enable or disable
specific logging you can call enable(int), disable(int), like:
// ... // Enable only DEBUG and INFO logging. Logger.disableAll(); Logger.enable(Logger.DEBUG | Logger.INFO); // ...to match your specific logging requirements.
DEBUG, INFO, WARN, ERROR| Modifier and Type | Class and Description |
|---|---|
static interface |
Logger.LogType
Defines an annotation for determining set of allowed log flags for
enable(...),
disable(...) methods. |
| Modifier and Type | Field and Description |
|---|---|
static int |
DEBUG
The flag to enable/disable log output for the DEBUG logging.
|
static int |
ERROR
The flag to enable/disable log output for the ERROR logging.
|
static int |
INFO
The flag to enable/disable log output for the INFO logging.
|
static int |
sEnabledLogs
Set of output flags determining which log outputs are enabled.
|
static int |
VERBOSE
The flag to enable/disable log output for the VERBOSE logging.
|
static int |
WARN
The flag to enable/disable log output for the WARN logging.
|
static int |
WTF
The flag to enable/disable log output for the WTF logging.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
d(String tag,
String msg)
Wrapped
Log.d(String, String). |
static void |
d(String tag,
String msg,
Throwable tr)
Wrapped
Log.d(String, String, Throwable). |
static void |
disable(int logFlag)
Disables the messages output in the log cat for the requested log output type/-s.
|
static void |
disableAll()
Disables the messages output in the log cat for all log output types.
|
static void |
e(String tag,
String msg)
Wrapped
Log.e(String, String). |
static void |
e(String tag,
String msg,
Throwable tr)
Wrapped
Log.e(String, String, Throwable). |
static void |
enable(int logFlag)
Enables the messages output in the log cat for the requested log output type/-s.
|
static void |
enableAll()
Enables the messages output in the log cat for the all log output types.
|
static String |
getStackTraceString(Throwable tr)
Wrapped
Log.getStackTraceString(Throwable). |
static void |
i(String tag,
String msg)
Wrapped
Log.i(String, String). |
static void |
i(String tag,
String msg,
Throwable tr)
Wrapped
Log.i(String, String, Throwable). |
static boolean |
isEnabled(int logFlag)
Returns flag indicating whether the log output for the specified logFlag is currently
enabled or not.
|
static boolean |
isLoggable(String tag,
int level)
Wrapped
Log.isLoggable(String, int). |
static void |
reset()
Resets the current state of Logger to the default one.
|
static void |
switchToDebugMode()
Enables all log outputs except
WTF. |
static void |
switchToReleaseMode()
|
static void |
v(String tag,
String msg)
Wrapped
Log.v(String, String). |
static void |
v(String tag,
String msg,
Throwable tr)
Wrapped
Log.v(String, String, Throwable). |
static void |
w(String tag,
String msg)
Wrapped
Log.w(String, String). |
static void |
w(String tag,
String msg,
Throwable tr)
Wrapped
Log.w(String, String, Throwable). |
static void |
w(String tag,
Throwable tr)
Wrapped
Log.w(String, Throwable). |
static void |
wtf(String tag,
String msg)
Wrapped
Log.wtf(String, String). |
static void |
wtf(String tag,
String msg,
Throwable tr)
Wrapped
Log.wtf(String, String, Throwable). |
static void |
wtf(String tag,
Throwable tr)
Wrapped
Log.wtf(String, Throwable). |
public static final int VERBOSE
v(String, String),
v(String, String, Throwable) for more info.public static final int DEBUG
d(String, String),
d(String, String, Throwable) for more info.public static final int INFO
i(String, String),
i(String, String, Throwable) for more info.public static final int WARN
w(String, String),
w(String, Throwable), w(String, String, Throwable) for more info.public static final int ERROR
e(String, String),
e(String, String, Throwable) for more info.public static final int WTF
wtf(String, String),
wtf(String, Throwable), wtf(String, String, Throwable) for more info.public static int sEnabledLogs
public static void reset()
public static void enable(int logFlag)
public static void disable(int logFlag)
public static void enableAll()
disableAll(),
isEnabled(int)public static void disableAll()
disableAll(),
isEnabled(int)public static boolean isEnabled(int logFlag)
public static void switchToDebugMode()
WTF. All currently enabled logs will be disabled.switchToReleaseMode()public static void switchToReleaseMode()
switchToDebugMode()public static void d(@NonNull String tag, @NonNull String msg)
Log.d(String, String).
Message will be outputted only, if the DEBUG flag is set.
public static void d(@NonNull String tag, @NonNull String msg, @Nullable Throwable tr)
Log.d(String, String, Throwable).
Message will be outputted only, if the DEBUG flag is set.
public static void v(@NonNull String tag, @NonNull String msg)
Log.v(String, String).
Message will be outputted only, if the VERBOSE flag is set.
public static void v(@NonNull String tag, @NonNull String msg, @Nullable Throwable tr)
Log.v(String, String, Throwable).
Message will be outputted only, if the VERBOSE flag is set.
public static void i(@NonNull String tag, @NonNull String msg)
Log.i(String, String).
Message will be outputted only, if the INFO flag is set.
public static void i(@NonNull String tag, @NonNull String msg, @Nullable Throwable tr)
Log.i(String, String, Throwable).
Message will be outputted only, if the INFO flag is set.
public static void w(@NonNull String tag, @NonNull String msg)
Log.w(String, String).
Message will be outputted only, if the WARN flag is set.
public static void w(@NonNull String tag, @Nullable Throwable tr)
Log.w(String, Throwable).
Message will be outputted only, if the WARN flag is set.
public static void w(@NonNull String tag, @NonNull String msg, @Nullable Throwable tr)
Log.w(String, String, Throwable).
Message will be outputted only, if the WARN flag is set.
public static void e(@NonNull String tag, @NonNull String msg)
Log.e(String, String).
Message will be outputted only, if the ERROR flag is set.
public static void e(@NonNull String tag, @NonNull String msg, @Nullable Throwable tr)
Log.e(String, String, Throwable).
Message will be outputted only, if the ERROR flag is set.
public static void wtf(@NonNull String tag, @NonNull String msg)
Log.wtf(String, String).
Message will be outputted only, if the WTF flag is set.
public static void wtf(@NonNull String tag, @Nullable Throwable tr)
Log.wtf(String, Throwable).
Message will be outputted only, if the WTF flag is set.
public static void wtf(@NonNull String tag, @NonNull String msg, @Nullable Throwable tr)
Log.wtf(String, String, Throwable).
Message will be outputted only, if the WTF flag is set.
public static boolean isLoggable(@NonNull String tag, int level)
Log.isLoggable(String, int).public static String getStackTraceString(@Nullable Throwable tr)
Log.getStackTraceString(Throwable).