Skip to content

Commit

Permalink
Reduced verbosity of nostr-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
arkanoider committed Sep 20, 2023
1 parent c59e9f2 commit 88adea6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ reqwest = { version = "0.11", features = ["json"] }
mostro-core = "0.2.8"
tokio-cron-scheduler = "*"
tracing = "0.1.37"
tracing-subscriber = "0.3.16"
tracing-subscriber = { version = "0.3.16", features =["env-filter"] }
config = "0.13.3"
10 changes: 9 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,23 @@ use nostr_sdk::prelude::*;
use scheduler::start_scheduler;
use settings::Settings;
use settings::{init_default_dir, init_global_settings};
use std::env;
use std::sync::Arc;
use std::{env::args, path::PathBuf, sync::OnceLock};
use tokio::sync::Mutex;
use tracing_subscriber::{fmt, prelude::*, EnvFilter};

static MOSTRO_CONFIG: OnceLock<Settings> = OnceLock::new();

#[tokio::main]
async fn main() -> Result<()> {
pretty_env_logger::init();
env::set_var("RUST_LOG", "none,mostro=info");

// Tracing using RUST_LOG
tracing_subscriber::registry()
.with(fmt::layer())
.with(EnvFilter::from_default_env())
.init();

let rate_list: Arc<Mutex<Vec<Event>>> = Arc::new(Mutex::new(vec![]));

Expand Down
7 changes: 1 addition & 6 deletions src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@ use std::error::Error;
use std::sync::Arc;
use tokio::sync::Mutex;
use tokio_cron_scheduler::{Job, JobScheduler};
use tracing::{info, warn, Level};
use tracing_subscriber::FmtSubscriber;
use tracing::{info, warn};

pub async fn start_scheduler(
rate_list: Arc<Mutex<Vec<Event>>>,
) -> Result<JobScheduler, Box<dyn Error>> {
let subscriber = FmtSubscriber::builder()
.with_max_level(Level::INFO)
.finish();
tracing::subscriber::set_global_default(subscriber).expect("Setting default subscriber failed");
info!("Creating scheduler");
let sched = JobScheduler::new().await?;
cron_scheduler(&sched, rate_list).await?;
Expand Down

0 comments on commit 88adea6

Please sign in to comment.