slog-rs - Structured, composable logging for Rust
Introduction
Inspired by log15 for Go.
Features
- easy to use
- hierarchical loggers
- lazily evaluated values
- modular and extensible
- small core create with multiple addon crates (
./crates/
) - compile only what you're actually using
- small core create with multiple addon crates (
- standard
log
crate logging support (slog-stdlog
crate) - drains & output formatting
- filtering
- multiple outputs
- asynchronous IO writing
- terminal output, with color support (
slog-term
crate) - Json (
slog-json
crate)- Bunyan (
slog-bunyan
crate)
- Bunyan (
- syslog (
slog-syslog
crate) - support for first class custom ones
Advantages over log
create
- composable and extensible logging drains - You can easily log messages to different destinations, in different formats, using different filtering rules. Building new drains and new output formats is very easy.
- drains are run-time swappable - Send a signal to your program and start logging everything to a file for run-time production debugging. Send another one when you're done to return to normal operation. Build your own flexible scenarios easily.
- non-global - Hierarchical loggers carry information about context of
logging. When logging an error condition, you want to know which resource was
being handled, on which instance of your service, using which source code
build, talking with what peer, etc. In standard
log
you would have to repeat this information in every log statement. Inslog
it will happen automatically. - both human and machine readable - By keeping the key-value data format, meaning of logging data is preserved. Dump your logging to a JSON file, and send it to your data-mining system for further analysis.
- lazy evaluation and asynchronous IO included
Terminal output example
Using & help
Code snippet
See examples/features.rs
for full code.
Read Documentation for details and features.
If you want to say hi, or need help use #dpc gitter.im.
To report a bug or ask for features use github issues.
Building & running
If you need to install Rust (come on, you should have done that long time ago!), use rustup.
In your project
In Cargo.toml:
[dependencies]
slog = "*"
In your main.rs
:
#[macro_use]
extern crate slog;