public final class LogCatcher
extends java.lang.Object
Notes:
LogCatcher
instance. If you need to capture the output from all your processes, you will have to instantiate one LogCatcher instance per process and capture the logs separately.LogCatcher.OnLogLinesListener.onLogLine(String)
. If it's not there, it's not captured yet.Modifier and Type | Class and Description |
---|---|
static interface |
LogCatcher.OnLogLinesListener
receive log lines and updates on the capture state
|
Constructor and Description |
---|
LogCatcher()
Default constructor.
|
LogCatcher(boolean clear)
Constructor.
|
LogCatcher(boolean clear,
boolean self)
Constructor.
|
LogCatcher(boolean clear,
boolean self,
java.util.concurrent.Executor executor)
Constructor.
|
LogCatcher(boolean clear,
int processId,
java.util.concurrent.Executor executor)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Best effort log eraser.
|
static void |
clearLog()
Best effort log eraser.
|
void |
dump(LogCatcher.OnLogLinesListener listener)
Capture the current log lines.
|
void |
endCapture()
Stop capturing log output
|
void |
startCapture(LogCatcher.OnLogLinesListener listener)
Starts to capture the log lines until
endCapture() is called. |
public LogCatcher(boolean clear, int processId, java.util.concurrent.Executor executor)
clear
- specify true
to clear the log, or false
to leave the log untouched.processId
- Specify a process id on which to filter the log.executor
- An Executor
on which to execute background tasks on. If null
is provided, the default background executor is obtained via Executors.newSingleThreadExecutor()
public LogCatcher(boolean clear, boolean self, java.util.concurrent.Executor executor)
clear
- specify true
to clear the log, or false
to leave the log untouched.self
- specify true
to capture only the log lines from your own application, or false
to capture the entire log.executor
- An Executor
on which to execute background tasks onpublic LogCatcher(boolean clear, boolean self)
clear
- specify true
to clear the log, or false
to leave the log untouched.self
- specify true
to capture only the log lines from your own application, or false
to capture the entire log.public LogCatcher()
public LogCatcher(boolean clear)
clear
- specify true
to clear the log, or false
to leave the log untouched.public void dump(LogCatcher.OnLogLinesListener listener)
adb logcat -d
listener
- a listener to receive log lines on the same thread that is executing the capture (e.g. your provided executor. If you didn't provide one, this is a background thread).public void startCapture(LogCatcher.OnLogLinesListener listener)
endCapture()
is called.listener
- A listener to receive log lines as they are logged.public void endCapture()
public static void clearLog()
public void clear()