-
- All Implemented Interfaces:
-
com.kaspersky.kaspresso.device.logcat.Logcat
public final class LogcatImpl implements Logcat
-
-
Constructor Summary
Constructors Constructor Description LogcatImpl(AdbServer adbServer, Boolean isNeededToPrintExecutedCommand, LogcatBufferSize defaultBufferSize)
-
Method Summary
Modifier and Type Method Description UnitdisableChatty()NOT WORKING ON ANDROID 8+The problem: Android OS has a special introduced mechanism to filter and collapse of some bunches of logs produced by applications. UnitsetBufferSize(LogcatBufferSize size)Set new logcat buffer size UnitsetDefaultBufferSize()Set default buffer size Unitclear(Logcat.Buffer buffer)Clear (flush) the selected buffers and exit. List<String>readLogcatRows(String excludePattern, Boolean excludePatternIsIgnoreCase, String includePattern, Boolean includePatternIsIgnoreCase, Logcat.Buffer buffer, Integer rowLimit)Get logcat dump as list of strings BooleanreadLogcatRows(String excludePattern, Boolean excludePatternIsIgnoreCase, String includePattern, Boolean includePatternIsIgnoreCase, Logcat.Buffer buffer, Integer rowLimit, Function1<String, Boolean> readingBlock)Get logcat dump and analyze each row. final BooleanreadLogcatRowsViaAdb(Regex excludePattern, Regex includePattern, Logcat.Buffer buffer, String logcatFilePath, Function1<String, Boolean> readingBlock)Required Permissions: READ_EXTERNAL_STORAGE. -
-
Constructor Detail
-
LogcatImpl
LogcatImpl(AdbServer adbServer, Boolean isNeededToPrintExecutedCommand, LogcatBufferSize defaultBufferSize)
-
-
Method Detail
-
disableChatty
Unit disableChatty()
NOT WORKING ON ANDROID 8+
The problem: Android OS has a special introduced mechanism to filter and collapse of some bunches of logs produced by applications. The name of the such mechanism is Chatty. Chatty turns on when an application writes a lot of logs. The goal of Logcat interface is to analyze all logs. But Chatty prevents achievement of the mentioned goal. That's why, there is this method to disable Chatty. Please, call the method in "before" section of a test.
-
setBufferSize
Unit setBufferSize(LogcatBufferSize size)
Set new logcat buffer size
- Parameters:
size- a LogcatBufferSize value
-
setDefaultBufferSize
Unit setDefaultBufferSize()
Set default buffer size
-
clear
Unit clear(Logcat.Buffer buffer)
Clear (flush) the selected buffers and exit. The default buffer set is main, system and crash.
- Parameters:
buffer- one of available logcat buffers
-
readLogcatRows
List<String> readLogcatRows(String excludePattern, Boolean excludePatternIsIgnoreCase, String includePattern, Boolean includePatternIsIgnoreCase, Logcat.Buffer buffer, Integer rowLimit)
Get logcat dump as list of strings
- Parameters:
excludePattern- logcat will EXCLUDE rows that match the patternexcludePatternIsIgnoreCase- boolean is exclude pattern must ignore string caseincludePattern- logcat will contains ONLY rows that match the patternincludePatternIsIgnoreCase- boolean is include pattern must ignore string casebuffer- one of available logcat buffersrowLimit- limiter of logcat output, starts FROM BEGINNING of logcat dump WITH EXTRA ROW of buffer beginning, if null return all rows
-
readLogcatRows
Boolean readLogcatRows(String excludePattern, Boolean excludePatternIsIgnoreCase, String includePattern, Boolean includePatternIsIgnoreCase, Logcat.Buffer buffer, Integer rowLimit, Function1<String, Boolean> readingBlock)
Get logcat dump and analyze each row. Logcat reading stops if analyzerBlock returns false on some row
- Parameters:
excludePattern- logcat will EXCLUDE rows that match the patternexcludePatternIsIgnoreCase- boolean is exclude pattern must ignore string caseincludePattern- logcat will contains ONLY rows that match the patternincludePatternIsIgnoreCase- boolean is include pattern must ignore string casebuffer- one of available logcat buffersrowLimit- limiter of logcat output, starts FROM BEGINNING of logcat dump WITH EXTRA ROW of buffer beginning, if null return all rowsreadingBlock- lambda with String input and Boolean output.
-
readLogcatRowsViaAdb
final Boolean readLogcatRowsViaAdb(Regex excludePattern, Regex includePattern, Logcat.Buffer buffer, String logcatFilePath, Function1<String, Boolean> readingBlock)
Required Permissions: READ_EXTERNAL_STORAGE. Required: Started AdbServer 1. Download a file "kaspresso/artifacts/adbserver-desktop.jar" 2. Start AdbServer => input in cmd "java jar path_to_file/adbserver-desktop.jar"
Get logcat dump via ADB and analyze each row. Logcat reading stops if analyzerBlock returns false on some row
Needed in cases when you want to check not only your application logs (with another PID). For example: if you need to check Firebase Analytics logs
- Parameters:
excludePattern- logcat will EXCLUDE rows that match the RegexincludePattern- logcat will contains ONLY rows that match the Regexbuffer- one of available logcat bufferslogcatFilePath- path on device where logcat_dump will located.readingBlock- lambda with String input and Boolean output.
-
-
-
-