建议日志 slog 改换 tracing

建议日志 slog 改换 tracing

(金庆的专栏 2021.11)

  • slog 不是立即写盘,最后的几行日志会丢失
    • tracing 不会丢日志
  • slog 不支持运行中动态更改日志等级
  • slog 不支持不同包设置不同日志等级
    • tracing 可单独打开某个模块的日志
  • 发现一次 slog panic: panicked at 'slog::Fuse Drain: Fatal(Custom { kind: BrokenPipe, error: "The logger thread terminated" })'
    • 搜到相同错误:https://github.com/mimblewimble/grin/issues/946
      • 别人的解决方法是: 不用slog了
  • slog 主页10月添加推荐使用 tracing
  • slog 按线程保存上下文,tracing 按协程保存上下文
  • tracing github star 1.9K > slog 1.2K
  • tracing crates 下载 21M > sloggers 0.4M, slog-scope 2.6M, slog-stdlog 1.9M
  • tracing vs slog: https://www.reddit.com/r/rust/comments/kdo29n/slog_vs_tracing_which_one_do_you_prefer/
  • Rust compiler 2020年已改用 tracing:https://github.com/rust-lang/rust/pull/74726
  • tracing 更好用
    • 文档及示例更全
    • 支持库更多
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值