IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    建议日志 slog 改换 tracing

    金庆发表于 2021-11-24 10:18:00
    love 0

    建议日志 slog 改换 tracing

    (金庆的专栏 2021.11)

    • slog 不是立即写盘,最后的几行日志会丢失

      • tracing 不会丢日志
    • slog 不支持运行中动态更改日志等级

      • tracing with_filter_reloading()

        • examples/tower-load
    • 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 更好用

      • 文档及示例更全
      • 支持库更多


    金庆 2021-11-24 18:18 发表评论


沪ICP备19023445号-2号
友情链接