Summary: Ctors | Methods | Inherited Methods | [Expand All]

# LogLogcatRule

`public class LogLogcatRule`
`` `` `extends LoggingBaseRule` ``

java.lang.Object
↳ | org.junit.rules.ExternalResource
| ↳ | android.support.test.rule.logging.LoggingBaseRule
|  | ↳ | android.support.test.rule.logging.LogLogcatRule

When applied to a test class this `Rule` attempts to clear the Logcat buffer on the device before test method execution. The `Rule` then collects everything in the Logcat buffer after test method execution and logs it to a file on external storage. The default file location is maintained at `getTestDir(String, String, int)`. The TestRule performs these actions through calling the device's logcat command.

Test methods can perform additional clearing and capturing of the Logcat buffer through the `clearLogcat()` and `dumpLogcat(String)` methods.

Usage: `\@Rule public LogLogcatRule mLogLogcatRule = new LogLogcatRule();`

## Summary

### Public constructors
`LogLogcatRule()`
`LogLogcatRule(File logFileOutputDirectory, String fileName)`

### Public methods
`void` | `afterTest()` Extract logcat buffer to a file after test run.
`void` | `beforeTest()` Clear logcat buffer prior to test run.
`static void` | `clearLogcat()` Clear the current logcat buffer.
`File` | `dumpLogcat(String logFileName)` Dump the current state of the logcat buffer to a file in the test method's logging directory.
`String` | `getDefaultLogFileName()` Return the default log file name for this rule class.

### Inherited methods
From class `android.support.test.rule.logging.LoggingBaseRule`
`final void` | `after()`
`final Statement` | `apply(Statement base, Description description)`
`final void` | `before()`
`String` | `getLogFileName()`
`File` | `getLogFileOutputDirectory()`
`String` | `getPackageNameUnderTest()`
`String` | `getTestClass()`
`String` | `getTestName()`
`int` | `getTestRunNumber()`
`void` | `setTestRunNumber(int testRunNumber)` Indicate to the `Rule` that this is the `testRunNumber`th time the test method is being called in a test instrumentation.
From class `org.junit.rules.ExternalResource`
`void` | `after()`
`Statement` | `apply(Statement arg0, Description arg1)`
`void` | `before()`
From class `java.lang.Object`
`Object` | `clone()`
`boolean` | `equals(Object arg0)`
`void` | `finalize()`
`final Class<?>` | `getClass()`
`int` | `hashCode()`
`final void` | `notify()`
`final void` | `notifyAll()`
`String` | `toString()`
`final void` | `wait(long arg0, int arg1)`
`final void` | `wait(long arg0)`
`final void` | `wait()`
From interface `org.junit.rules.TestRule`
`abstract Statement` | `apply(Statement arg0, Description arg1)`

## Public constructors

### LogLogcatRule

    LogLogcatRule ()

### LogLogcatRule

    LogLogcatRule (File logFileOutputDirectory,
                    String fileName)

Parameters
`logFileOutputDirectory` | `File`
`fileName` | `String`

## Public methods

### afterTest

    void afterTest ()

Extract logcat buffer to a file after test run.

### beforeTest

    void beforeTest ()

Clear logcat buffer prior to test run.

### clearLogcat

    void clearLogcat ()

Clear the current logcat buffer. This can be called from test method code, but will alter the results of the `Rule`'s final log of the buffer at the end of the test method.

### dumpLogcat

    File dumpLogcat (String logFileName)

Dump the current state of the logcat buffer to a file in the test method's logging directory. This method can be used when writing tests to record logcat at different points in time.

Parameters
`logFileName` | `String`: where Logcat output is sent

Returns
`File` | the `File` where output was logged

### getDefaultLogFileName

    String getDefaultLogFileName ()

Return the default log file name for this rule class. A null return value indicates the rule doesn't log to a file.

Returns
`String` |

- ## Classes

  - AtraceLogger
  - EnableTestTracingRule
  - LogBatteryInformationRule
  - LogDeviceGetPropInfoRule
  - LoggingBaseRule
  - LogGraphicsStatsRule
  - LogLogcatRule
  - LogNetStatsRule
  - RuleLoggingUtils