# `NervesHubLink.Extensions.Logging.Batched`
[🔗](https://github.com/nerves-hub/nerves_hub_link/blob/v2.14.0/lib/nerves_hub_link/extensions/logging/batched.ex#L5)

The Logging Extension, version 0.1.0.

Sends the device's log lines to NervesHub, where they are stored against the
device and made searchable. One direction only: nothing is ever sent back.

`NervesHubLink.Extensions.Logging` is version 0.0.1 of the same extension and
lives alongside this one. They are the same feature, and naming either one in
`extension_modules` configures both:

    config :nerves_hub_link,
      extension_modules: [
        NervesHubLink.Extensions.Geo,
        NervesHubLink.Extensions.Health,
        NervesHubLink.Extensions.LocalShell,
        NervesHubLink.Extensions.NetworkIdentity,
        NervesHubLink.Extensions.Logging
      ]

There is nothing to add for this module. A device offers whichever version
the platform has and prefers this one where it is available.

## What 0.1.0 changes

0.0.1 sends a message per line. NervesHub limits how often a device may send
rather than how much it may say, so that is a limit on lines: a device in a
crash loop loses almost everything it writes, and the survivors are an
arbitrary sample rather than the part worth reading.

This version collects lines in
`NervesHubLink.Extensions.Logging.Collector` and sends a minute of them at a
time, in messages of up to a hundred lines. The same send budget then carries
a minute of logs rather than a handful of lines.

The collector also runs from application start rather than from the attach,
so what a device writes while booting, while offline, or while NervesHub is
deciding whether it wants logging at all is still there to send.

## Configuration

    config :nerves_hub_link,
      logging: [
        level: :info,
        max_lines: 1000,
        interval_seconds: 60
      ]

`level` is shared with 0.0.1. `max_lines` is how many lines the collector
holds before dropping the oldest, and `interval_seconds` is never less than
60 whatever it is set to.

# `flush`

```elixir
@spec flush() :: :ok
```

Send whatever has collected, without waiting for the next flush.

## Examples

    iex> NervesHubLink.Extensions.Logging.flush()
    :ok

---

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