Skip to content

Commit

Permalink
refactor: replace log with tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
itsusinn committed Feb 5, 2022
1 parent 5353382 commit 5350e29
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ teloxide-core = { version = "0.3.3",default-features = false, features = ["rustl
teloxide-macros = "0.4.1"

# logging
env_logger = "0.9.0"
log = "0.4.14"
tracing="0.1.29"
tracing-subscriber = { version = "0.3.6", features = ["env-filter","tracing-log"]}
log="0.4.14"

# serialization
serde = { version = "1.0.130",default-features = false,features = ["derive","rc"] }
Expand Down Expand Up @@ -56,9 +57,9 @@ reqwest = { version = "0.11.9" ,default-features = false ,features = ["rustls","
sled = "0.34.7"

# mesagisto
nats = "0.16.0"
mesagisto-client = { rev = "68f0505", git = "https://github.com/MeowCat-Studio/mesagisto-client-rs.git"}
# mesagisto-client = { path = "../../mesagisto-client/rust" }
nats = "0.17.0"
# mesagisto-client = { rev = "414e33", git = "https://github.com/MeowCat-Studio/mesagisto-client-rs.git"}
mesagisto-client = { path = "../../mesagisto-client/rust" }
automatic-config = { git = "https://github.com/Itsusinn/automatic-config-rs.git" }
singleton = { git = "https://github.com/Itsusinn/singleton-rs.git", rev = "bee321c" }
# singleton = { path = "/home/itsusinn/Workspace/Code/singleton-rs" }
Expand Down
17 changes: 6 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![allow(incomplete_features)]
#![feature(backtrace, capture_disjoint_fields)]

use env_logger::TimestampPrecision;
use futures::FutureExt;
use mesagisto_client::MesagistoConfig;
use std::sync::Arc;
Expand All @@ -28,20 +27,16 @@ mod webhook;

#[tokio::main]
async fn main() {

env_logger::builder()
.write_style(env_logger::WriteStyle::Auto)
.filter(None, log::LevelFilter::Error)
.format_timestamp(Some(TimestampPrecision::Seconds))
.filter(Some("telegram_message_source"), log::LevelFilter::Info)
.filter(Some("mesagisto_client"), log::LevelFilter::Info)
.filter(Some("teloxide"), log::LevelFilter::Info)
.init();

run().await.unwrap();
}
#[allow(unused_must_use)]
async fn run() -> Result<(), anyhow::Error> {
let env = tracing_subscriber::EnvFilter::from("warn")
.add_directive("teloxide=info".parse()?)
.add_directive("telegram_message_source=info".parse()?)
.add_directive("mesagisto_client=info".parse()?);
tracing_subscriber::fmt().with_env_filter(env).init();

if !CONFIG.enable {
log::warn!("Mesagisto-Bot is not enabled and is about to exit the program.");
log::warn!("To enable it, please modify the configuration file.");
Expand Down

0 comments on commit 5350e29

Please sign in to comment.