# `DalaDev.Bench.Logger`
[🔗](https://github.com/manhvu/dala_dev/blob/main/lib/dala_dev/bench/logger.ex#L1)

Append-only CSV log of bench probe snapshots.

Format:

    ts_ms,elapsed_sec,reachability,app_process,usb,screen,battery_pct,reason

Reading:
- `ts_ms` is monotonic — safe to subtract for intervals
- `elapsed_sec` is seconds since the run started (set on `open/2`)
- `reachability`, `app_process`, `usb`, `screen` are atoms (string-encoded)
- `battery_pct` is integer or empty
- `reason` is a string (CSV-escaped)

Use `summary/1` after a run to compute % success, gap distribution,
reconnect count, etc.

# `t`

```elixir
@type t() :: %DalaDev.Bench.Logger{
  file: File.io_device() | nil,
  path: Path.t(),
  rows: non_neg_integer(),
  start_ts_ms: integer()
}
```

# `append`

```elixir
@spec append(t(), DalaDev.Bench.Probe.t()) :: t()
```

Append a probe snapshot. Returns the updated logger struct.

# `close`

```elixir
@spec close(t()) :: t()
```

Close the log file. Idempotent.

# `open`

```elixir
@spec open(
  Path.t(),
  keyword()
) :: t()
```

Open a log file for writing. Creates parent dirs as needed.

Returns a struct that's passed to subsequent `append/2` and `close/1` calls.

# `read`

```elixir
@spec read(Path.t()) :: [map()]
```

Read a CSV file and return a list of probe-like maps. Useful for tests
and for `summary/1`.

Each row is `%{ts_ms, elapsed_sec, reachability, app_process, usb,
screen, battery_pct, reason}` with atoms restored.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
