9 releases (5 breaking)

0.6.0 Feb 7, 2024
0.5.0 Jan 16, 2024
0.4.0 Dec 15, 2023
0.3.2 Oct 25, 2023
0.1.0 Jan 19, 2023

#362 in Debugging

Download history 59/week @ 2023-12-22 87/week @ 2023-12-29 15/week @ 2024-01-05 82/week @ 2024-01-12 299/week @ 2024-01-19 1/week @ 2024-01-26 140/week @ 2024-02-02 62/week @ 2024-02-09 295/week @ 2024-02-16 77/week @ 2024-02-23 214/week @ 2024-03-01 87/week @ 2024-03-08 294/week @ 2024-03-15 348/week @ 2024-03-22 157/week @ 2024-03-29 127/week @ 2024-04-05

930 downloads per month

Apache-2.0

130KB
2.5K SLoC

This crate provides an asynchronous logging backend that can direct logs to one or more outputs.

The core of this crate is the RingLog type, which is constructed using a builder that is specific to your logging needs. After building the RingLog, it can be registered as the global logger using the start method. You will be left with a Box<dyn Drain> which should be periodically flushed outside of any critical path. For example, in an admin thread or dedicated logging thread.

For logging to a single file, the LogBuilder type can be used to construct an RingLog which has low overhead, but directs log messages to a single Output.

A SamplingLogBuilder can be used to construct an RingLog which will filter the log messages using sampling before directing the log messages to a single Output.

A MultiLogBuilder can be used to construct an RingLog which routes log messages based on the target metadata of the log Record. If there is an RingLog registered for that specific target, then the log message will be routed to that instance of RingLog. Log messages that do not match any specific target will be routed to the default RingLog that has been added to the MultiLogBuilder. If there is no default, messages that do not match any specific target will be simply dropped.

This combination of logging types allows us to compose a logging backend which meets the application's needs. For example, you can use a local log macro to set the target to some specific category and log those messages to a file, while letting all other log messages pass to standard out. This could allow splitting command/access/audit logs from the normal logging.

Dependencies

~4–11MB
~89K SLoC