1 unstable release
Uses old Rust 2015
0.0.1 | Oct 22, 2019 |
---|
#8 in #routine
8KB
177 lines
Composable logging with monoids and contravariant functors.
If you want to use this library there are at least two ways to obtain it: you could depend on it with Cargo by adding contralog as a dependency in Cargo.toml, or you could copy the src/lib.rs file into your own project under a different name.
When developing this library please use Nix to ensure the build is reproducible:
nix run -ic cargo test
lib.rs
:
Composable logging with monoids and contravariant functors.
A logger is a routine that takes input and has side-effects. Any routine that has the appropriate type will do. A logger can be seen as the opposite or dual of an infinite iterator.
The core trait of this crate is Logger. It has only a single method that must be implemented: log. To log something, pass it to this method. It is up to the logger to decide what to do with the value.
Loggers are composable: given two loggers with compatible types, a new logger can be created that forwards its input to both loggers.
Loggers can also be transformed using methods such as map and filter.