#tracing-subscriber #formatter #format #events #glog #glog-inspired #glog-fields

tracing-glog

tracing-subscriber 的 glog 启发式格式化器

7 个不稳定版本 (3 个破坏性更新)

0.4.0 2024年4月12日
0.3.0 2023年8月7日
0.2.3 2023年8月7日
0.2.2 2022年10月27日
0.1.1 2021年12月1日

#50日期和时间

Download history 579/week @ 2024-04-26 308/week @ 2024-05-03 260/week @ 2024-05-10 610/week @ 2024-05-17 424/week @ 2024-05-24 381/week @ 2024-05-31 199/week @ 2024-06-07 264/week @ 2024-06-14 532/week @ 2024-06-21 504/week @ 2024-06-28 930/week @ 2024-07-05 1155/week @ 2024-07-12 1021/week @ 2024-07-19 985/week @ 2024-07-26 1305/week @ 2024-08-02 759/week @ 2024-08-09

每月4,298次下载
用于 5 crates

MIT/Apache

36KB
650

tracing-glog

tracing-glog 是一个 glog 启发式的 tracing-subscriber 格式化器。

tracing-glog 应与 tracing-subscriber 一起使用,因为它是一个格式化器,允许 tracing-subscriberfmt::Subscriberfmt::Layer 以 glog 启发式的方式格式化事件。

示例

使用 fmt::Subscriber

use tracing_glog::{Glog, GlogFields};

tracing_subscriber::fmt()
    .event_format(Glog::default())
    .fmt_fields(GlogFields::default())
    .init();

使用 tracing_subscriber::fmt::Layer

use tracing_subscriber::prelude::*;
use tracing_subscriber::{fmt, Registry};
use tracing_glog::{Glog, GlogFields};

let fmt = fmt::Layer::default()
    .event_format(Glog::default())
    .fmt_fields(GlogFields::default());

let subscriber = Registry::default().with(fmt);
tracing::subscriber::set_global_default(subscriber).expect("Unable to set global subscriber");

依赖项

~2.4–9MB
~54K SLoC