A library for sending all tracing errors to your telegram bot user_id in private chat
Here is simplest usage:
use std::env;
use tracing::Level;
fn main() {
let api = Api::new(config.bot_key());
let user_id = env::var("TELEGRAM_USER_ID").expect("TELEGRAM_USER_ID not set").parse::<i64>().expect("TELEGRAM_USER_ID must be i64");
tracing_tg_bot_subscriber::new(api.clone())
.set_user_id(user_id)
.set_bot_level(Level::WARN)
.set_debug_level(Level::INFO)
.register();
Ok(())
}
You can rely on the library to recognize data from environment variables on its own:
use std::env;
use tracing::Level;
fn main() {
// TELEGRAM_USER_ID env variable in use
// if not specified, it will not lead any errors or warnings, but will not send messages to admin
// Default bot tracing level is Level::ERROR
// Default debug tracing level is Level::WARN
let api = Api::new(config.bot_key());
tracing_tg_bot_subscriber::new(api.clone())
.register();
Ok(())
}