feat(cli): Remove --debug flag

This commit is contained in:
Binarybaron 2025-10-21 16:11:55 +02:00
parent 815692af5b
commit 9af6bcc504
6 changed files with 53 additions and 87 deletions

View file

@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
- ASB + GUI + CLI: Fix an issue where the internal Tor client would fail to choose guards. This would prevent all Tor traffic from working. We temporarily fix this by forcing new guards to be chosen on every startup. This will be reverted once the issue is fixed [upstream](https://gitlab.torproject.org/tpo/core/arti/-/issues/2079) - ASB + GUI + CLI: Fix an issue where the internal Tor client would fail to choose guards. This would prevent all Tor traffic from working. We temporarily fix this by forcing new guards to be chosen on every startup. This will be reverted once the issue is fixed [upstream](https://gitlab.torproject.org/tpo/core/arti/-/issues/2079)
- CLI: Remove the `--debug` flag
## [3.2.0-rc.4] - 2025-10-17 ## [3.2.0-rc.4] - 2025-10-17

View file

@ -173,7 +173,6 @@ pub async fn initialize_context(
}) })
.with_monero(settings.monero_node_config) .with_monero(settings.monero_node_config)
.with_json(false) .with_json(false)
.with_debug(true)
.with_tor(settings.use_tor) .with_tor(settings.use_tor)
.with_enable_monero_tor(settings.enable_monero_tor) .with_enable_monero_tor(settings.enable_monero_tor)
.with_tauri(tauri_handle.clone()) .with_tauri(tauri_handle.clone())

View file

@ -43,7 +43,6 @@ use swap_env::config::{
}; };
use swap_feed; use swap_feed;
use swap_machine::alice::is_complete; use swap_machine::alice::is_complete;
use tracing_subscriber::filter::LevelFilter;
use uuid::Uuid; use uuid::Uuid;
const DEFAULT_WALLET_NAME: &str = "asb-wallet"; const DEFAULT_WALLET_NAME: &str = "asb-wallet";
@ -53,8 +52,7 @@ fn initialize_tracing(json: bool, config: &Config, trace: bool) -> Result<()> {
let format = if json { Format::Json } else { Format::Raw }; let format = if json { Format::Json } else { Format::Raw };
let log_dir = config.data.dir.join("logs"); let log_dir = config.data.dir.join("logs");
common::tracing_util::init(LevelFilter::DEBUG, format, log_dir, None, trace) common::tracing_util::init(format, log_dir, None, trace).expect("initialize tracing");
.expect("initialize tracing");
tracing::info!( tracing::info!(
binary = "asb", binary = "asb",

View file

@ -40,7 +40,6 @@ mod config {
pub(super) namespace: XmrBtcNamespace, pub(super) namespace: XmrBtcNamespace,
pub env_config: EnvConfig, pub env_config: EnvConfig,
pub(super) seed: Option<Seed>, pub(super) seed: Option<Seed>,
pub(super) debug: bool,
pub(super) json: bool, pub(super) json: bool,
pub(super) log_dir: PathBuf, pub(super) log_dir: PathBuf,
pub(super) data_dir: PathBuf, pub(super) data_dir: PathBuf,
@ -57,7 +56,6 @@ mod config {
namespace: XmrBtcNamespace::from_is_testnet(false), namespace: XmrBtcNamespace::from_is_testnet(false),
env_config, env_config,
seed: seed.into(), seed: seed.into(),
debug: false,
json: false, json: false,
is_testnet: false, is_testnet: false,
data_dir, data_dir,
@ -417,7 +415,6 @@ mod builder {
bitcoin: Option<Bitcoin>, bitcoin: Option<Bitcoin>,
data: Option<PathBuf>, data: Option<PathBuf>,
is_testnet: bool, is_testnet: bool,
debug: bool,
json: bool, json: bool,
tor: bool, tor: bool,
enable_monero_tor: bool, enable_monero_tor: bool,
@ -441,7 +438,6 @@ mod builder {
bitcoin: None, bitcoin: None,
data: None, data: None,
is_testnet: false, is_testnet: false,
debug: false,
json: false, json: false,
tor: false, tor: false,
enable_monero_tor: false, enable_monero_tor: false,
@ -480,12 +476,6 @@ mod builder {
self self
} }
/// Whether to include debug level logging messages (default false)
pub fn with_debug(mut self, debug: bool) -> Self {
self.debug = debug;
self
}
/// Set logging format to json (default false) /// Set logging format to json (default false)
pub fn with_json(mut self, json: bool) -> Self { pub fn with_json(mut self, json: bool) -> Self {
self.json = json; self.json = json;
@ -515,19 +505,13 @@ mod builder {
// Initialize logging // Initialize logging
let format = if self.json { Format::Json } else { Format::Raw }; let format = if self.json { Format::Json } else { Format::Raw };
let level_filter = if self.debug {
LevelFilter::from_level(Level::DEBUG)
} else {
LevelFilter::from_level(Level::INFO)
};
START.call_once(|| { START.call_once(|| {
let _ = common::tracing_util::init( let _ = common::tracing_util::init(
level_filter,
format, format,
log_dir.clone(), log_dir.clone(),
self.tauri_handle.clone(), self.tauri_handle.clone(),
false, true,
); );
tracing::info!( tracing::info!(
binary = "cli", binary = "cli",
@ -716,7 +700,6 @@ mod builder {
namespace: XmrBtcNamespace::from_is_testnet(self.is_testnet), namespace: XmrBtcNamespace::from_is_testnet(self.is_testnet),
env_config, env_config,
seed: seed.clone().into(), seed: seed.clone().into(),
debug: self.debug,
json: self.json, json: self.json,
is_testnet: self.is_testnet, is_testnet: self.is_testnet,
data_dir: data_dir.clone(), data_dir: data_dir.clone(),
@ -1165,7 +1148,6 @@ pub mod api_test {
namespace: XmrBtcNamespace::from_is_testnet(is_testnet), namespace: XmrBtcNamespace::from_is_testnet(is_testnet),
env_config, env_config,
seed: seed.into(), seed: seed.into(),
debug,
json, json,
is_testnet, is_testnet,
data_dir, data_dir,

View file

@ -54,10 +54,10 @@ where
Err(e) => anyhow::bail!(e), Err(e) => anyhow::bail!(e),
}; };
let debug = args.debug;
let json = args.json; let json = args.json;
let is_testnet = args.testnet; let is_testnet = args.testnet;
let data = args.data; let data = args.data;
let result: Result<Arc<Context>> = match args.cmd { let result: Result<Arc<Context>> = match args.cmd {
CliCommand::BuyXmr { CliCommand::BuyXmr {
seller: Seller { seller }, seller: Seller { seller },
@ -85,7 +85,6 @@ where
.with_bitcoin(bitcoin) .with_bitcoin(bitcoin)
.with_monero(monero) .with_monero(monero)
.with_data_dir(data) .with_data_dir(data)
.with_debug(debug)
.with_json(json) .with_json(json)
.build(context.clone()) .build(context.clone())
.await?; .await?;
@ -105,7 +104,6 @@ where
let context = Arc::new(Context::new_without_tauri_handle()); let context = Arc::new(Context::new_without_tauri_handle());
ContextBuilder::new(is_testnet) ContextBuilder::new(is_testnet)
.with_data_dir(data) .with_data_dir(data)
.with_debug(debug)
.with_json(json) .with_json(json)
.build(context.clone()) .build(context.clone())
.await?; .await?;
@ -122,7 +120,6 @@ where
let context = Arc::new(Context::new_without_tauri_handle()); let context = Arc::new(Context::new_without_tauri_handle());
ContextBuilder::new(is_testnet) ContextBuilder::new(is_testnet)
.with_data_dir(data) .with_data_dir(data)
.with_debug(debug)
.with_json(json) .with_json(json)
.build(context.clone()) .build(context.clone())
.await?; .await?;
@ -141,7 +138,6 @@ where
let context = Arc::new(Context::new_without_tauri_handle()); let context = Arc::new(Context::new_without_tauri_handle());
ContextBuilder::new(is_testnet) ContextBuilder::new(is_testnet)
.with_data_dir(data) .with_data_dir(data)
.with_debug(debug)
.with_json(json) .with_json(json)
.build(context.clone()) .build(context.clone())
.await?; .await?;
@ -155,7 +151,6 @@ where
ContextBuilder::new(is_testnet) ContextBuilder::new(is_testnet)
.with_bitcoin(bitcoin) .with_bitcoin(bitcoin)
.with_data_dir(data) .with_data_dir(data)
.with_debug(debug)
.with_json(json) .with_json(json)
.build(context.clone()) .build(context.clone())
.await?; .await?;
@ -179,7 +174,6 @@ where
ContextBuilder::new(is_testnet) ContextBuilder::new(is_testnet)
.with_bitcoin(bitcoin) .with_bitcoin(bitcoin)
.with_data_dir(data) .with_data_dir(data)
.with_debug(debug)
.with_json(json) .with_json(json)
.build(context.clone()) .build(context.clone())
.await?; .await?;
@ -202,7 +196,6 @@ where
.with_bitcoin(bitcoin) .with_bitcoin(bitcoin)
.with_monero(monero) .with_monero(monero)
.with_data_dir(data) .with_data_dir(data)
.with_debug(debug)
.with_json(json) .with_json(json)
.build(context.clone()) .build(context.clone())
.await?; .await?;
@ -219,7 +212,6 @@ where
ContextBuilder::new(is_testnet) ContextBuilder::new(is_testnet)
.with_bitcoin(bitcoin) .with_bitcoin(bitcoin)
.with_data_dir(data) .with_data_dir(data)
.with_debug(debug)
.with_json(json) .with_json(json)
.build(context.clone()) .build(context.clone())
.await?; .await?;
@ -238,7 +230,6 @@ where
ContextBuilder::new(is_testnet) ContextBuilder::new(is_testnet)
.with_tor(tor.enable_tor) .with_tor(tor.enable_tor)
.with_data_dir(data) .with_data_dir(data)
.with_debug(debug)
.with_json(json) .with_json(json)
.build(context.clone()) .build(context.clone())
.await?; .await?;
@ -256,7 +247,6 @@ where
ContextBuilder::new(is_testnet) ContextBuilder::new(is_testnet)
.with_bitcoin(bitcoin) .with_bitcoin(bitcoin)
.with_data_dir(data) .with_data_dir(data)
.with_debug(debug)
.with_json(json) .with_json(json)
.build(context.clone()) .build(context.clone())
.await?; .await?;
@ -271,7 +261,6 @@ where
let context = Arc::new(Context::new_without_tauri_handle()); let context = Arc::new(Context::new_without_tauri_handle());
ContextBuilder::new(is_testnet) ContextBuilder::new(is_testnet)
.with_data_dir(data) .with_data_dir(data)
.with_debug(debug)
.with_json(json) .with_json(json)
.build(context.clone()) .build(context.clone())
.await?; .await?;
@ -310,9 +299,6 @@ struct Arguments {
)] )]
data: Option<PathBuf>, data: Option<PathBuf>,
#[structopt(long, help = "Activate debug logging")]
debug: bool,
#[structopt( #[structopt(
short, short,
long = "json", long = "json",

View file

@ -13,46 +13,47 @@ use tracing_subscriber::{fmt, EnvFilter, Layer};
use crate::cli::api::tauri_bindings::{TauriEmitter, TauriHandle, TauriLogEvent}; use crate::cli::api::tauri_bindings::{TauriEmitter, TauriHandle, TauriLogEvent};
const TOR_CRATES: &[&str] = &[ const TOR_CRATES: &[&str] = &["arti", "arti_client"];
"arti",
"arti-client", #[allow(dead_code)] // might be useful later
"arti-fork", const TOR_SUBCRATES: &[&str] = &[
"tor-api2", "arti_fork",
"tor-async-utils", "tor_api2",
"tor-basic-utils", "tor_async_utils",
"tor-bytes", "tor_basic_utils",
"tor-cell", "tor_bytes",
"tor-cert", "tor_cell",
"tor-chanmgr", "tor_cert",
"tor-checkable", "tor_chanmgr",
"tor-circmgr", "tor_checkable",
"tor-config", "tor_circmgr",
"tor-config-path", "tor_config",
"tor-consdiff", "tor_config_path",
"tor-dirclient", "tor_consdiff",
"tor-dirmgr", "tor_dirclient",
"tor-error", "tor_dirmgr",
"tor-general-addr", "tor_error",
"tor-guardmgr", "tor_general_addr",
"tor-hsclient", "tor_guardmgr",
"tor-hscrypto", "tor_hsclient",
"tor-hsservice", "tor_hscrypto",
"tor-key-forge", "tor_hsservice",
"tor-keymgr", "tor_key_forge",
"tor-linkspec", "tor_keymgr",
"tor-llcrypto", "tor_linkspec",
"tor-log-ratelim", "tor_llcrypto",
"tor-memquota", "tor_log_ratelim",
"tor-netdir", "tor_memquota",
"tor-netdoc", "tor_netdir",
"tor-persist", "tor_netdoc",
"tor-proto", "tor_persist",
"tor-protover", "tor_proto",
"tor-relay-selection", "tor_protover",
"tor-rtcompat", "tor_relay_selection",
"tor-rtmock", "tor_rtcompat",
"tor-socksproto", "tor_rtmock",
"tor-units", "tor_socksproto",
"tor_units",
]; ];
const LIBP2P_CRATES: &[&str] = &[ const LIBP2P_CRATES: &[&str] = &[
@ -83,19 +84,19 @@ const LIBP2P_CRATES: &[&str] = &[
"libp2p_gossipsub", "libp2p_gossipsub",
"libp2p_rendezvous", "libp2p_rendezvous",
"libp2p_dcutr", "libp2p_dcutr",
"monero_cpp",
]; ];
const OUR_CRATES: &[&str] = &[ const OUR_CRATES: &[&str] = &[
"swap", "swap",
"asb", "asb",
"monero_sys", "monero_sys",
"unstoppableswap-gui-rs", "unstoppableswap_gui_rs",
"seed", "seed",
"swap_env", "swap_env",
"swap_fs", "swap_fs",
"swap_serde", "swap_serde",
"monero_rpc_pool", "monero_rpc_pool",
"monero_cpp",
]; ];
/// Output formats for logging messages. /// Output formats for logging messages.
@ -112,7 +113,6 @@ pub enum Format {
/// disregarding the arguments to this function. When `trace_stdout` is `true`, /// disregarding the arguments to this function. When `trace_stdout` is `true`,
/// all tracing logs are also emitted to stdout. /// all tracing logs are also emitted to stdout.
pub fn init( pub fn init(
level_filter: LevelFilter,
format: Format, format: Format,
dir: impl AsRef<Path>, dir: impl AsRef<Path>,
tauri_handle: Option<TauriHandle>, tauri_handle: Option<TauriHandle>,
@ -143,7 +143,7 @@ pub fn init(
.json() .json()
.with_filter(env_filter_with_all_crates(vec![( .with_filter(env_filter_with_all_crates(vec![(
OUR_CRATES.to_vec(), OUR_CRATES.to_vec(),
level_filter, LevelFilter::DEBUG,
)])?); )])?);
// Layer for writing to the verbose log file // Layer for writing to the verbose log file
@ -187,7 +187,7 @@ pub fn init(
.with_line_number(true) .with_line_number(true)
.json() .json()
.with_filter(env_filter_with_all_crates(vec![ .with_filter(env_filter_with_all_crates(vec![
(OUR_CRATES.to_vec(), LevelFilter::DEBUG), (OUR_CRATES.to_vec(), LevelFilter::TRACE),
(LIBP2P_CRATES.to_vec(), LevelFilter::INFO), (LIBP2P_CRATES.to_vec(), LevelFilter::INFO),
(TOR_CRATES.to_vec(), LevelFilter::INFO), (TOR_CRATES.to_vec(), LevelFilter::INFO),
])?); ])?);
@ -196,11 +196,11 @@ pub fn init(
// Otherwise, we only log the bare minimum // Otherwise, we only log the bare minimum
let terminal_layer_env_filter = match trace_stdout { let terminal_layer_env_filter = match trace_stdout {
true => env_filter_with_all_crates(vec![ true => env_filter_with_all_crates(vec![
(OUR_CRATES.to_vec(), level_filter), (OUR_CRATES.to_vec(), LevelFilter::DEBUG),
(TOR_CRATES.to_vec(), level_filter), (TOR_CRATES.to_vec(), LevelFilter::INFO),
(LIBP2P_CRATES.to_vec(), LevelFilter::INFO), (LIBP2P_CRATES.to_vec(), LevelFilter::INFO),
])?, ])?,
false => env_filter_with_all_crates(vec![(OUR_CRATES.to_vec(), level_filter)])?, false => env_filter_with_all_crates(vec![(OUR_CRATES.to_vec(), LevelFilter::INFO)])?,
}; };
let final_terminal_layer = match format { let final_terminal_layer = match format {
@ -222,7 +222,7 @@ pub fn init(
subscriber.try_init()?; subscriber.try_init()?;
// Now we can use the tracing macros to log messages // Now we can use the tracing macros to log messages
tracing::info!(%level_filter, logs_dir=%dir.as_ref().display(), "Initialized tracing. General logs will be written to swap-all.log, and verbose logs to tracing*.log"); tracing::info!(logs_dir=%dir.as_ref().display(), "Initialized tracing. General logs will be written to swap-all.log, and verbose logs to tracing*.log");
Ok(()) Ok(())
} }