Holds the device's log lines until the Logging extension sends them.
Runs from application start, not from the extension being attached. Lines written while a device is booting, or while it is offline, or while NervesHub is still deciding whether it wants logging at all, are the ones an operator goes looking for, and none of them exist by the time the extension starts.
The bound
A device can write faster than a minute's worth of lines can be sent, and a device the platform never attaches keeps writing regardless. So this holds a fixed number of lines and drops the oldest past it, counting what went. The count goes out as a line of its own ahead of the survivors, because a gap someone can see beats a gap they cannot.
Where the lines come from
A :logger handler, which runs in the process doing the logging. Everything
it does is a send/2 to this process, since anything slower would charge the
application for the reporting, and anything that logs would recurse.
Summary
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec count() :: non_neg_integer()
How many lines are waiting, the drop notice included.
@spec sent(non_neg_integer()) :: :ok
Forget the first count lines take/1 returned, now that they have gone.
@spec start_link(keyword()) :: GenServer.on_start()
Start collecting.
Options
:max_lines- how many lines to hold. Defaults to whatNervesHubLink.Extensions.Logging.Config.max_lines/0reports.:level- the lowest level to collect, asLoggernames it. Defaults to:info. Filtering happens in:logger, so a line below this costs the application nothing.
@spec take(pos_integer()) :: [map()]
The next lines to send, oldest first, at most max of them.
Left where they are. Paired with sent/1 rather than handing them over,
because a push can fail and lines taken out of here and then not sent are
exactly what this exists to prevent.