feat(main): advanced logger instantiation
This commit is contained in:
parent
6d4666c12d
commit
6cb2d47a8d
|
@ -961,6 +961,7 @@ dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"colog",
|
"colog",
|
||||||
"colored",
|
"colored",
|
||||||
|
"env_logger",
|
||||||
"itertools",
|
"itertools",
|
||||||
"log",
|
"log",
|
||||||
"nostr-sdk",
|
"nostr-sdk",
|
||||||
|
|
|
@ -16,6 +16,7 @@ xdg = "2.5"
|
||||||
itertools = "0.12"
|
itertools = "0.12"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
|
env_logger = "0.11"
|
||||||
colog = "1.3"
|
colog = "1.3"
|
||||||
colored = "2.1"
|
colored = "2.1"
|
||||||
nostr-sdk = "0.33"
|
nostr-sdk = "0.33"
|
||||||
|
|
20
src/main.rs
20
src/main.rs
|
@ -14,8 +14,9 @@ use std::sync::mpsc::Sender;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
|
use env_logger::Builder;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use log::{debug, error, info, trace, warn};
|
use log::{debug, error, info, LevelFilter, trace, warn};
|
||||||
use nostr_sdk::prelude::*;
|
use nostr_sdk::prelude::*;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use xdg::BaseDirectories;
|
use xdg::BaseDirectories;
|
||||||
|
@ -101,7 +102,20 @@ impl Drop for EventSender {
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
colog::init();
|
let mut args = args().skip(1).peekable();
|
||||||
|
if args.peek().is_some_and(|arg| arg == "--debug") {
|
||||||
|
args.next();
|
||||||
|
Builder::new()
|
||||||
|
.filter(None, LevelFilter::Debug)
|
||||||
|
.filter(Some("mostr"), LevelFilter::Trace)
|
||||||
|
.parse_default_env()
|
||||||
|
.init();
|
||||||
|
} else {
|
||||||
|
colog::default_builder()
|
||||||
|
.filter(Some("nostr-relay-pool"), LevelFilter::Error)
|
||||||
|
//.filter(Some("nostr-relay-pool::relay::internal"), LevelFilter::Off)
|
||||||
|
.init();
|
||||||
|
}
|
||||||
|
|
||||||
let config_dir = or_print(BaseDirectories::new())
|
let config_dir = or_print(BaseDirectories::new())
|
||||||
.and_then(|d| or_print(d.create_config_directory("mostr")))
|
.and_then(|d| or_print(d.create_config_directory("mostr")))
|
||||||
|
@ -254,7 +268,7 @@ async fn main() {
|
||||||
|
|
||||||
{
|
{
|
||||||
let tasks = selected_relay.as_ref().and_then(|url| relays.get_mut(&url)).unwrap_or_else(|| &mut local_tasks);
|
let tasks = selected_relay.as_ref().and_then(|url| relays.get_mut(&url)).unwrap_or_else(|| &mut local_tasks);
|
||||||
for argument in args().skip(1) {
|
for argument in args {
|
||||||
tasks.make_task(&argument);
|
tasks.make_task(&argument);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue