# AtraceLogger

Artifact: [androidx.test:rules](https://developer.android.com/jetpack/androidx/releases/test) [View Source](https://cs.android.com/search?q=file:androidx/test/rule/logging/AtraceLogger.java+class:androidx.test.rule.logging.AtraceLogger)

*** ** * ** ***


```
class AtraceLogger
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> unsupported. Consider running trace from host such as via Android Studio

Class contains helper methods to dump atrace info asynchronously while running the test case.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[atraceStart](https://developer.android.com/reference/kotlin/androidx/test/rule/logging/AtraceLogger#atraceStart(java.util.Set<java.lang.String>,int,int,java.io.File,java.lang.String))( traceCategoriesSet: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!, atraceBufferSize: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, dumpIntervalSecs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, destDirectory: https://developer.android.com/reference/java/io/File.html!, traceFileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html! )` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[atraceStop](https://developer.android.com/reference/kotlin/androidx/test/rule/logging/AtraceLogger#atraceStop())()` **This function is deprecated.** Deprecated in Java |
| `java-static https://developer.android.com/reference/kotlin/androidx/test/rule/logging/AtraceLogger!` | `[getAtraceLoggerInstance](https://developer.android.com/reference/kotlin/androidx/test/rule/logging/AtraceLogger#getAtraceLoggerInstance(android.app.Instrumentation))(instrumentation: https://developer.android.com/reference/android/app/Instrumentation.html!)` **This function is deprecated.** Deprecated in Java |

## Public functions

### atraceStart

```
fun [atraceStart](https://developer.android.com/reference/kotlin/androidx/test/rule/logging/AtraceLogger#atraceStart(java.util.Set<java.lang.String>,int,int,java.io.File,java.lang.String))(
    traceCategoriesSet: (Mutable)Set<String!>!,
    atraceBufferSize: Int,
    dumpIntervalSecs: Int,
    destDirectory: File!,
    traceFileName: String!
): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Method to start atrace and dump the data at regular interval. Note : Trace info will not be captured during the dumping if there are multiple dumps between the atraceStart and atraceStop

| Parameters |
|---|---|
| `traceCategoriesSet: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!` | Set of atrace categories (i.e atrace --list_categories) |
| `atraceBufferSize: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Size of the circular buffer in kb |
| `dumpIntervalSecs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Periodic interval to dump data from circular buffer |
| `destDirectory: https://developer.android.com/reference/java/io/File.html!` | Directory under which atrace logs are stored |
| `traceFileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | is optional parameter.Atrace files are dumped under destDirectory. traceFileName will be indexed based on number of dumps between atraceStart and atraceStop under destDirectory. If traceFileName is null or empty "atrace" name will be used for indexing the files and stored under destDirectory |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |

### atraceStop

```
fun [atraceStop](https://developer.android.com/reference/kotlin/androidx/test/rule/logging/AtraceLogger#atraceStop())(): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Method to stop the atrace and write the atrace data cached in byte array list to file.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |
| `https://developer.android.com/reference/java/lang/InterruptedException.html` |   |

### getAtraceLoggerInstance

```
java-static fun [getAtraceLoggerInstance](https://developer.android.com/reference/kotlin/androidx/test/rule/logging/AtraceLogger#getAtraceLoggerInstance(android.app.Instrumentation))(instrumentation: Instrumentation!): AtraceLogger!
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

To make sure only one instance of atrace logger is created.

| Parameters |
|---|---|
| `instrumentation: https://developer.android.com/reference/android/app/Instrumentation.html!` | Used to execute atrace shell commands |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/rule/logging/AtraceLogger!` | instance of the AtraceLogger |