public class Debug
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Debug.OnLogListener |
| Modifier and Type | Field and Description |
|---|---|
static int |
LOG_ALL |
static int |
LOG_COMMAND |
static int |
LOG_GENERAL |
static int |
LOG_NONE |
static int |
LOG_OUTPUT |
static java.lang.String |
TAG |
| Constructor and Description |
|---|
Debug() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
getDebug()
Is debug mode enabled ?
|
static boolean |
getLogTypeEnabled(int type)
Is logging for specific types of messages enabled ?
|
static boolean |
getLogTypeEnabledEffective(int type)
Is logging for specific types of messages enabled ?
|
static Debug.OnLogListener |
getOnLogListener()
Get the currently registered custom log handler
|
static boolean |
getSanityChecksEnabled()
Are sanity checks enabled ?
|
static boolean |
getSanityChecksEnabledEffective()
Are sanity checks enabled ?
|
static void |
log(java.lang.String message)
Log a "general" message
|
static void |
logCommand(java.lang.String message)
Log a "per-command" message
|
static void |
logOutput(java.lang.String message)
Log a line of stdout/stderr output
|
static boolean |
onMainThread()
Are we running on the main thread ?
|
static void |
setDebug(boolean enable)
Enable or disable debug mode
|
static void |
setLogTypeEnabled(int type,
boolean enable)
Enable or disable logging specific types of message
|
static void |
setOnLogListener(Debug.OnLogListener onLogListener)
Register a custom log handler
|
static void |
setSanityChecksEnabled(boolean enable)
Enable or disable sanity checks
|
public static final java.lang.String TAG
public static final int LOG_GENERAL
public static final int LOG_COMMAND
public static final int LOG_OUTPUT
public static final int LOG_NONE
public static final int LOG_ALL
public static void setDebug(boolean enable)
Enable or disable debug mode
By default, debug mode is enabled for development builds and disabled for exported APKs - see BuildConfig.DEBUG
enable - Enable debug mode ?public static boolean getDebug()
Is debug mode enabled ?
public static void log(java.lang.String message)
Log a "general" message
These messages are infrequent and mostly occur at startup/shutdown or on error
message - The message to logpublic static void logCommand(java.lang.String message)
Log a "per-command" message
This could produce a lot of output if the client runs many commands in the session
message - The message to logpublic static void logOutput(java.lang.String message)
Log a line of stdout/stderr output
This could produce a lot of output if the shell commands are noisy
message - The message to logpublic static void setLogTypeEnabled(int type,
boolean enable)
Enable or disable logging specific types of message
You may | (or) LOG_* constants together. Note that debug mode must also be enabled for actual logging to occur.
type - LOG_* constantsenable - Enable or disablepublic static boolean getLogTypeEnabled(int type)
Is logging for specific types of messages enabled ?
You may | (or) LOG_* constants together, to learn if all passed message types are enabled for logging. Note that debug mode must also be enabled for actual logging to occur.
type - LOG_* constantspublic static boolean getLogTypeEnabledEffective(int type)
Is logging for specific types of messages enabled ?
You may | (or) LOG_* constants together, to learn if all message types are enabled for logging. Takes debug mode into account for the result.
type - LOG_* constantspublic static void setOnLogListener(Debug.OnLogListener onLogListener)
Register a custom log handler
Replaces the log method (write to logcat) with your own handler. Whether your handler gets called is still dependent on debug mode and message types being enabled for logging.
onLogListener - Custom log listener or NULL to revert to defaultpublic static Debug.OnLogListener getOnLogListener()
Get the currently registered custom log handler
public static void setSanityChecksEnabled(boolean enable)
Enable or disable sanity checks
Enables or disables the library crashing when su is called from the main thread.
enable - Enable or disablepublic static boolean getSanityChecksEnabled()
Are sanity checks enabled ?
Note that debug mode must also be enabled for actual sanity checks to occur.
public static boolean getSanityChecksEnabledEffective()
Are sanity checks enabled ?
Takes debug mode into account for the result.
public static boolean onMainThread()
Are we running on the main thread ?