# `PhoenixReplay.Capture.Logs`
[🔗](https://github.com/elixir-vibe/phoenix_replay/blob/v0.6.2/lib/phoenix_replay/capture/logs.ex#L1)

Records log messages in the session of the process that logged them.

    config :phoenix_replay, logs: [level: :info, metadata: [:request_id]]

## Options

  * `:level` — the lowest level recorded. Defaults to `:info`. Messages
    below the `:logger` primary level are never emitted at all.
  * `:metadata` — Logger metadata keys to keep. Defaults to `[]`.
  * `:limit` — log messages recorded per session. Defaults to `1_000`.

This is a `:logger` handler. `:logger` calls handlers in the process that
logs, so a message belongs to the session of that process, or of the
first of its `$callers` that has one, as for
`PhoenixReplay.Capture.TelemetryEvents`. Messages are formatted on one line,
their metadata goes through the session's `PhoenixReplay.Sanitizer`, and
each is recorded as a `:log` event. Their text is masked when the
recording is saved, by the session's `PhoenixReplay.Redactor`.

`:logger` removes a handler that raises, so failures are reported with
`[:phoenix_replay, :collector, :exception]` instead.

# `attach`

```elixir
@spec attach(PhoenixReplay.Config.t(), atom()) :: :ok | {:error, term()}
```

Adds the `:logger` handler when `:logs` is configured. Called by
`PhoenixReplay.Capture.Handlers`.

# `detach`

```elixir
@spec detach(atom()) :: :ok
```

Removes the `:logger` handler, if added.

# `log`

```elixir
@spec log(:logger.log_event(), :logger.handler_config()) :: :ok
```

The `:logger` handler callback: records `event` in the session of the
process that logged it, or of the LiveView that started it.

---

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