# `RingLogger.Client`
[🔗](https://github.com/nerves-project/ring_logger/blob/v0.11.7/lib/ring_logger/client.ex#L1)

Interact with the RingLogger

# `attach`

```elixir
@spec attach(GenServer.server()) :: :ok
```

Attach the current IEx session to the logger. It will start printing log messages.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `config`

```elixir
@spec config(pid()) :: RingLogger.client_options()
```

Fetch the current client configuration.

# `configure`

```elixir
@spec configure(GenServer.server(), RingLogger.client_options()) :: :ok
```

Update the client configuration.

Options include:
* `:io` - Defaults to `:stdio`
* `:colors` -
* `:metadata` - A KV list of additional metadata
* `:format` - A custom format string, or a {module, function} tuple (see
  https://logger.hexdocs.pm/master/Logger.html#module-custom-formatting)
* `:level` - The minimum log level to report.
* `:module_levels` - a map of log level overrides per module. For example,
  %{MyModule => :error, MyOtherModule => :none}
* `:application_levels` - a map of log level overrides per application. For example,
  %{:my_app => :error, :my_other_app => :none}. Note log levels set in `:module_levels`
  will take precedence.

# `configure_module_levels`

```elixir
@spec configure_module_levels(RingLogger.client_options()) :: map()
```

# `count_next`

```elixir
@spec count_next(GenServer.server()) :: non_neg_integer()
```

Count the next set of the messages in the log.

# `detach`

```elixir
@spec detach(GenServer.server()) :: :ok
```

Detach the current IEx session from the logger.

# `format`

```elixir
@spec format(GenServer.server(), RingLogger.entry()) :: :ok
```

Helper method for formatting log messages per the current client's
configuration.

# `grep`

```elixir
@spec grep(GenServer.server(), String.t() | Regex.t(), RingLogger.client_options()) ::
  :ok | {:error, term()}
```

Run a regular expression on each entry in the log and print out the matchers.

Supported options:

* `:pager` - an optional 2-arity function that takes an IO device and what to print
* `:before` - Number of lines before the match to include
* `:after` - NUmber of lines after the match to include

# `grep_metadata`

```elixir
@spec grep_metadata(
  GenServer.server(),
  atom(),
  String.t() | Regex.t(),
  RingLogger.client_options()
) :: :ok | {:error, term()}
```

# `next`

```elixir
@spec next(GenServer.server(), RingLogger.client_options()) :: :ok | {:error, term()}
```

Get the next set of the messages in the log.

Supported options:

* `:pager` - an optional 2-arity function that takes an IO device and what to print

# `reset`

```elixir
@spec reset(GenServer.server()) :: :ok
```

Reset the index into the log for `tail/1` to the oldest entry.

# `save`

```elixir
@spec save(GenServer.server(), Path.t()) :: :ok | {:error, term()}
```

Format and save all log messages to the specified path.

# `start_link`

```elixir
@spec start_link(RingLogger.client_options()) :: GenServer.on_start()
```

Start up a client GenServer. Except for just getting the contents of the ring buffer, you'll
need to create one of these. See `configure/2` for information on options.

# `stop`

```elixir
@spec stop(GenServer.server()) :: :ok
```

Stop a client.

# `tail`

```elixir
@spec tail(GenServer.server(), non_neg_integer(), RingLogger.client_options()) ::
  :ok | {:error, term()}
```

Get the last n messages.

Supported options:

* `:pager` - an optional 2-arity function that takes an IO device and what to print

---

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