https://github.com/dpc/slog-rs
给大家推荐一款看起来很好用的日志库,小编个人觉得是目前Rust社区最好用的日志库了(欢迎筒子来打脸),小声说小编还没用过,不过看介绍心里痒痒的。
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
standard
log
crate logging support (slog-stdlog
crate)drains & output formatting
Bunyan (
slog-bunyan
crate)filtering
multiple outputs
asynchronous IO writing
terminal output, with color support (
slog-term
crate)Json (
slog-json
crate)syslog (
slog-syslog
crate)support for first class custom ones
Advantages over log
crate
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
大家可以尝试一下。