4 个版本

0.1.3 2023年1月28日
0.1.2 2022年6月30日
0.1.1 2021年5月19日
0.1.0 2021年5月17日

#1116 in 开发工具

Download history 16/week @ 2024-03-12 1/week @ 2024-03-26 6/week @ 2024-04-02

81 每月下载

MIT/Apache 许可

21KB
137 代码行

Sentry 与 log4rs 的集成

Crates.io version Documentation

此 crate 提供了将 sentry 与 log4rs 集成的支持。

快速入门

log4rs.yaml

refresh_rate: 30 seconds
appenders:
  stdout:
    kind: console
  
  sentry_demo:
    kind: sentry
    encoder:
      pattern: "{m}"
    dsn: "https://[email protected]/42" # Your Sentry DSN here
    threshold: error

root:
  level: info
  appenders:
    - stdout
    - sentry_demo

main.rs

use log::{error, info};
use log4rs;
use sentry_log4rs::SentryAppender;

fn main() {
    log4rs::init_file("log4rs.yaml", SentryAppender::deserializers()).unwrap();

    info!("booting up");
    error!("[yaml-config] Something went wrong!");
	// ...
}

测试

可以使用 examples/yaml_config.rsexample/code_config.rs 示例进行功能测试,只需更新 dsn 值并运行即可

    cargo run --example code_config
    cargo run --example yaml_config

许可证

依赖项

~6MB
~145K SLoC