Package 

Class LogcatImpl

  • All Implemented Interfaces:
    com.kaspersky.kaspresso.device.logcat.Logcat

    
    public final class LogcatImpl
     implements Logcat
                        
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public class Companion
    • Method Summary

      Modifier and Type Method Description
      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.
      Unit setBufferSize(LogcatBufferSize size) Set new logcat buffer size
      Unit setDefaultBufferSize() Set default buffer size
      Unit clear(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
      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.
      final Boolean readLogcatRowsViaAdb(Regex excludePattern, Regex includePattern, Logcat.Buffer buffer, String logcatFilePath, Function1<String, Boolean> readingBlock) Required Permissions: READ_EXTERNAL_STORAGE.
      • Methods inherited from class com.kaspersky.kaspresso.device.logcat.Logcat

        equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.

      • 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 pattern
        excludePatternIsIgnoreCase - boolean is exclude pattern must ignore string case
        includePattern - logcat will contains ONLY rows that match the pattern
        includePatternIsIgnoreCase - boolean is include pattern must ignore string case
        buffer - one of available logcat buffers
        rowLimit - 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 pattern
        excludePatternIsIgnoreCase - boolean is exclude pattern must ignore string case
        includePattern - logcat will contains ONLY rows that match the pattern
        includePatternIsIgnoreCase - boolean is include pattern must ignore string case
        buffer - one of available logcat buffers
        rowLimit - limiter of logcat output, starts FROM BEGINNING of logcat dump WITH EXTRA ROW of buffer beginning, if null return all rows
        readingBlock - 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 Regex
        includePattern - logcat will contains ONLY rows that match the Regex
        buffer - one of available logcat buffers
        logcatFilePath - path on device where logcat_dump will located.
        readingBlock - lambda with String input and Boolean output.