Changed log to tracing
This commit is contained in:
parent
db12bba7a6
commit
48a14823fa
26 changed files with 321 additions and 689 deletions
|
|
@ -25,8 +25,8 @@ dht = {path="../dht", package="librqbit-dht", version="2.2.2"}
|
|||
tokio = {version = "1", features = ["macros", "rt-multi-thread"]}
|
||||
anyhow = "1"
|
||||
clap = {version = "4", features = ["derive", "deprecated"]}
|
||||
log = "0.4"
|
||||
pretty_env_logger = "0.5"
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = {version = "0.3", features = ["env-filter"]}
|
||||
regex = "1"
|
||||
futures = "0.3"
|
||||
parse_duration = "2"
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ use librqbit::{
|
|||
},
|
||||
spawn_utils::{spawn, BlockingSpawner},
|
||||
};
|
||||
use log::{error, info, warn};
|
||||
use size_format::SizeFormatterBinary as SF;
|
||||
use tracing::{error, info, span, warn, Level};
|
||||
|
||||
#[derive(Debug, Clone, Copy, ValueEnum)]
|
||||
enum LogLevel {
|
||||
|
|
@ -151,7 +151,13 @@ fn init_logging(opts: &Opts) {
|
|||
}
|
||||
};
|
||||
}
|
||||
pretty_env_logger::init();
|
||||
|
||||
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
|
||||
|
||||
tracing_subscriber::registry()
|
||||
.with(fmt::layer())
|
||||
.with(EnvFilter::from_default_env())
|
||||
.init();
|
||||
}
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
|
|
@ -258,7 +264,10 @@ async fn async_main(opts: Opts, spawner: BlockingSpawner) -> anyhow::Result<()>
|
|||
.await
|
||||
.context("error initializing rqbit session")?,
|
||||
);
|
||||
spawn("Stats printer", stats_printer(session.clone()));
|
||||
spawn(
|
||||
span!(Level::TRACE, "stats_printer"),
|
||||
stats_printer(session.clone()),
|
||||
);
|
||||
let http_api = HttpApi::new(session);
|
||||
let http_api_listen_addr = opts.http_api_listen_addr;
|
||||
http_api
|
||||
|
|
@ -331,11 +340,14 @@ async fn async_main(opts: Opts, spawner: BlockingSpawner) -> anyhow::Result<()>
|
|||
.await
|
||||
.context("error initializing rqbit session")?,
|
||||
);
|
||||
spawn("Stats printer", stats_printer(session.clone()));
|
||||
spawn(
|
||||
span!(Level::TRACE, "stats_printer"),
|
||||
stats_printer(session.clone()),
|
||||
);
|
||||
let http_api = HttpApi::new(session.clone());
|
||||
let http_api_listen_addr = opts.http_api_listen_addr;
|
||||
spawn(
|
||||
"HTTP API",
|
||||
span!(Level::ERROR, "http_api"),
|
||||
http_api.clone().make_http_api_and_run(http_api_listen_addr),
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue