7 个版本

0.2.0 2024年3月17日
0.1.5 2023年6月27日
0.1.2 2023年3月15日

调试 中排名第 242

Download history 29/week @ 2024-04-05 31/week @ 2024-04-12 28/week @ 2024-04-19 46/week @ 2024-04-26 64/week @ 2024-05-03 45/week @ 2024-05-10 54/week @ 2024-05-17 36/week @ 2024-05-24 35/week @ 2024-05-31 35/week @ 2024-06-07 42/week @ 2024-06-14 40/week @ 2024-06-21 31/week @ 2024-06-28 40/week @ 2024-07-05 43/week @ 2024-07-12 5/week @ 2024-07-19

每月下载 128

MIT 许可证

27KB
534 代码行

rummage —— 收集编译时和运行时环境信息以进行调试日志记录

Latest Version Documentation License

rummage 提供了一种简单且具有见解的方式,用于收集一系列合理的编译时和运行时环境信息,并以结构化的 tracing 事件输出。

示例用法

fn main() {
    tracing_subscriber::fmt()
        .json()
        .with_max_level(tracing::Level::DEBUG)
        .init();

    // Collect the default info set, plus the three named environment variables
    let info = rummage::info!().with_envvars(["RUST_LOG", "HOME", "PWD"]);
    
    // Emit the gathered info as a set of structured log messages
    info.log_debug();
}
会输出如下内容(使用 `jq` 格式化以提高可读性)
{
  "timestamp": "2023-03-15T23:14:00.634339Z",
  "level": "DEBUG",
  "fields": {
    "message": "Crate information:",
    "git_commit_hash": "3acb2d157c80c720a306e1ea11c5d026167cfeda",
    "git_repo_dirty": true,
    "crate_name": "rummage_demo",
    "crate_version": "0.1.0",
    "bin_name": "rummage-demo"
  },
  "target": "rummage"
}
{
  "timestamp": "2023-03-15T23:14:00.634413Z",
  "level": "DEBUG",
  "fields": {
    "message": "Cargo target information:",
    "profile": "debug",
    "host": "x86_64-unknown-linux-gnu",
    "target": "x86_64-unknown-linux-gnu",
    "family": "unix",
    "os": "linux",
    "arch": "x86_64",
    "pointer_width": "64",
    "endian": "little",
    "features": "fxsr,sse,sse2"
  },
  "target": "rummage"
}
{
  "timestamp": "2023-03-15T23:14:00.634437Z",
  "level": "DEBUG",
  "fields": {
    "message": "Rustc information:",
    "rustc_semver": "1.68.0",
    "commit_hash": "2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74",
    "commit_date": "2023-03-06",
    "llvm_version": "15.0"
  },
  "target": "rummage"
}
{
  "timestamp": "2023-03-15T23:14:00.634451Z",
  "level": "DEBUG",
  "fields": {
    "message": "System information:",
    "hostname": "DESKTOP-0E64KFA",
    "os": "Linux 5.10.102.1-microsoft-standard-WSL2",
    "linux_distro": "Ubuntu 22.04.1 LTS",
    "cpu_vendor": "AuthenticAMD",
    "cpu_brand_string": "AMD Ryzen 9 3950X 16-Core Processor"
  },
  "target": "rummage"
}
{
  "timestamp": "2023-03-15T23:14:00.634469Z",
  "level": "DEBUG",
  "fields": {
    "message": "Command line args:",
    "args": "[\"target/debug/rummage-demo\", \"--foo=10\", \"--bar\", \"apple\"]"
  },
  "target": "rummage"
}
{
  "timestamp": "2023-03-15T23:14:00.634484Z",
  "level": "DEBUG",
  "fields": {
    "message": "Environment variables:",
    "args": "{\"RUST_LOG\": Some(\"debug\"), \"HOME\": Some(\"/home/joe\"), \"PWD\": Some(\"/home/joe/dev/rummage-demo\")}"
  },
  "target": "rummage"
}

依赖项

~1.4–2.6MB
~48K SLoC