slog-rs - Structured, composable logging for Rust

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. In slog 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

大家可以尝试一下。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值