mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-22 13:02:21 -04:00
fix: don't log tracing messages from other crates
This commit is contained in:
parent
b060c75cc7
commit
853164b7c7
2 changed files with 13 additions and 8 deletions
|
@ -189,7 +189,7 @@ impl Context {
|
||||||
|
|
||||||
let format = if json { Format::Json } else { Format::Raw };
|
let format = if json { Format::Json } else { Format::Raw };
|
||||||
let level_filter = if debug {
|
let level_filter = if debug {
|
||||||
LevelFilter::from_level(Level::DEBUG)
|
LevelFilter::from_level(Level::DEBUG)
|
||||||
} else {
|
} else {
|
||||||
LevelFilter::from_level(Level::INFO)
|
LevelFilter::from_level(Level::INFO)
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use tracing::Level;
|
use tracing_subscriber::filter::{Directive, LevelFilter};
|
||||||
use tracing_subscriber::filter::LevelFilter;
|
|
||||||
use tracing_subscriber::fmt::time::UtcTime;
|
use tracing_subscriber::fmt::time::UtcTime;
|
||||||
use tracing_subscriber::layer::SubscriberExt;
|
use tracing_subscriber::layer::SubscriberExt;
|
||||||
use tracing_subscriber::{fmt, Layer};
|
use tracing_subscriber::{fmt, EnvFilter, Layer};
|
||||||
use tracing_subscriber::util::SubscriberInitExt;
|
use tracing_subscriber::util::SubscriberInitExt;
|
||||||
|
|
||||||
/// Output formats for logging messages.
|
/// Output formats for logging messages.
|
||||||
|
@ -25,9 +25,14 @@ pub fn init(
|
||||||
format: Format,
|
format: Format,
|
||||||
dir: impl AsRef<Path>,
|
dir: impl AsRef<Path>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
if level_filter == LevelFilter::OFF {
|
let env_filter = EnvFilter::from_default_env()
|
||||||
return Ok(());
|
.add_directive(Directive::from_str(
|
||||||
}
|
&format!(
|
||||||
|
"asb={}",
|
||||||
|
&level_filter,
|
||||||
|
)
|
||||||
|
)?)
|
||||||
|
.add_directive(Directive::from_str(&format!("swap={}", &level_filter))?);
|
||||||
|
|
||||||
// file logger will always write in JSON format and with timestamps
|
// file logger will always write in JSON format and with timestamps
|
||||||
let file_appender = tracing_appender::rolling::never(&dir, "swap-all.log");
|
let file_appender = tracing_appender::rolling::never(&dir, "swap-all.log");
|
||||||
|
@ -38,7 +43,7 @@ pub fn init(
|
||||||
.with_timer(UtcTime::rfc_3339())
|
.with_timer(UtcTime::rfc_3339())
|
||||||
.with_target(false)
|
.with_target(false)
|
||||||
.json()
|
.json()
|
||||||
.with_filter(LevelFilter::from_level(Level::DEBUG));
|
.with_filter(env_filter);
|
||||||
|
|
||||||
// terminal logger
|
// terminal logger
|
||||||
let is_terminal = atty::is(atty::Stream::Stderr);
|
let is_terminal = atty::is(atty::Stream::Stderr);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue