mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-11-24 09:53:09 -05:00
feat(asb): add trace flag for stdout (#366)
* fix(asb): include trace option in raw arguments * feat(asb): Add --trace flag
This commit is contained in:
parent
274c630aba
commit
a33ebfbb3a
5 changed files with 79 additions and 16 deletions
|
|
@ -9,6 +9,7 @@ import { getDataDir, initializeContext } from "renderer/rpc";
|
||||||
import { relaunch } from "@tauri-apps/plugin-process";
|
import { relaunch } from "@tauri-apps/plugin-process";
|
||||||
import RotateLeftIcon from "@material-ui/icons/RotateLeft";
|
import RotateLeftIcon from "@material-ui/icons/RotateLeft";
|
||||||
import { revealItemInDir } from "@tauri-apps/plugin-opener";
|
import { revealItemInDir } from "@tauri-apps/plugin-opener";
|
||||||
|
import { TauriContextStatusEvent } from "models/tauriModel";
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
actionsOuter: {
|
actionsOuter: {
|
||||||
|
|
@ -24,13 +25,13 @@ export default function DaemonControlBox() {
|
||||||
|
|
||||||
// The daemon can be manually started if it has failed or if it has not been started yet
|
// The daemon can be manually started if it has failed or if it has not been started yet
|
||||||
const canContextBeManuallyStarted = useAppSelector(
|
const canContextBeManuallyStarted = useAppSelector(
|
||||||
(s) => s.rpc.status?.type === "Failed" || s.rpc.status === null,
|
(s) => s.rpc.status === TauriContextStatusEvent.Failed || s.rpc.status === null,
|
||||||
);
|
);
|
||||||
const isContextInitializing = useAppSelector(
|
const isContextInitializing = useAppSelector(
|
||||||
(s) => s.rpc.status?.type === "Initializing",
|
(s) => s.rpc.status === TauriContextStatusEvent.Initializing,
|
||||||
);
|
);
|
||||||
|
|
||||||
const stringifiedDaemonStatus = useAppSelector((s) => s.rpc.status?.type ?? "not started");
|
const stringifiedDaemonStatus = useAppSelector((s) => s.rpc.status ?? "not started");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<InfoBox
|
<InfoBox
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ where
|
||||||
let args = RawArguments::from_clap(&matches);
|
let args = RawArguments::from_clap(&matches);
|
||||||
|
|
||||||
let json = args.json;
|
let json = args.json;
|
||||||
|
let trace = args.trace;
|
||||||
let testnet = args.testnet;
|
let testnet = args.testnet;
|
||||||
let config = args.config;
|
let config = args.config;
|
||||||
let command: RawCommand = args.cmd;
|
let command: RawCommand = args.cmd;
|
||||||
|
|
@ -28,6 +29,7 @@ where
|
||||||
RawCommand::Start { resume_only } => Arguments {
|
RawCommand::Start { resume_only } => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
|
trace,
|
||||||
config_path: config_path(config, testnet)?,
|
config_path: config_path(config, testnet)?,
|
||||||
env_config: env_config(testnet),
|
env_config: env_config(testnet),
|
||||||
cmd: Command::Start { resume_only },
|
cmd: Command::Start { resume_only },
|
||||||
|
|
@ -35,6 +37,7 @@ where
|
||||||
RawCommand::History { only_unfinished } => Arguments {
|
RawCommand::History { only_unfinished } => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
|
trace,
|
||||||
config_path: config_path(config, testnet)?,
|
config_path: config_path(config, testnet)?,
|
||||||
env_config: env_config(testnet),
|
env_config: env_config(testnet),
|
||||||
cmd: Command::History { only_unfinished },
|
cmd: Command::History { only_unfinished },
|
||||||
|
|
@ -46,6 +49,7 @@ where
|
||||||
} => Arguments {
|
} => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
|
trace,
|
||||||
config_path: config_path(config, testnet)?,
|
config_path: config_path(config, testnet)?,
|
||||||
env_config: env_config(testnet),
|
env_config: env_config(testnet),
|
||||||
cmd: Command::Logs {
|
cmd: Command::Logs {
|
||||||
|
|
@ -57,6 +61,7 @@ where
|
||||||
RawCommand::WithdrawBtc { amount, address } => Arguments {
|
RawCommand::WithdrawBtc { amount, address } => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
|
trace,
|
||||||
config_path: config_path(config, testnet)?,
|
config_path: config_path(config, testnet)?,
|
||||||
env_config: env_config(testnet),
|
env_config: env_config(testnet),
|
||||||
cmd: Command::WithdrawBtc {
|
cmd: Command::WithdrawBtc {
|
||||||
|
|
@ -67,6 +72,7 @@ where
|
||||||
RawCommand::Balance => Arguments {
|
RawCommand::Balance => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
|
trace,
|
||||||
config_path: config_path(config, testnet)?,
|
config_path: config_path(config, testnet)?,
|
||||||
env_config: env_config(testnet),
|
env_config: env_config(testnet),
|
||||||
cmd: Command::Balance,
|
cmd: Command::Balance,
|
||||||
|
|
@ -74,6 +80,7 @@ where
|
||||||
RawCommand::Config => Arguments {
|
RawCommand::Config => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
|
trace,
|
||||||
config_path: config_path(config, testnet)?,
|
config_path: config_path(config, testnet)?,
|
||||||
env_config: env_config(testnet),
|
env_config: env_config(testnet),
|
||||||
cmd: Command::Config,
|
cmd: Command::Config,
|
||||||
|
|
@ -81,6 +88,7 @@ where
|
||||||
RawCommand::ExportBitcoinWallet => Arguments {
|
RawCommand::ExportBitcoinWallet => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
|
trace,
|
||||||
config_path: config_path(config, testnet)?,
|
config_path: config_path(config, testnet)?,
|
||||||
env_config: env_config(testnet),
|
env_config: env_config(testnet),
|
||||||
cmd: Command::ExportBitcoinWallet,
|
cmd: Command::ExportBitcoinWallet,
|
||||||
|
|
@ -91,6 +99,7 @@ where
|
||||||
}) => Arguments {
|
}) => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
|
trace,
|
||||||
config_path: config_path(config, testnet)?,
|
config_path: config_path(config, testnet)?,
|
||||||
env_config: env_config(testnet),
|
env_config: env_config(testnet),
|
||||||
cmd: Command::Redeem {
|
cmd: Command::Redeem {
|
||||||
|
|
@ -104,6 +113,7 @@ where
|
||||||
}) => Arguments {
|
}) => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
|
trace,
|
||||||
config_path: config_path(config, testnet)?,
|
config_path: config_path(config, testnet)?,
|
||||||
env_config: env_config(testnet),
|
env_config: env_config(testnet),
|
||||||
cmd: Command::Cancel { swap_id },
|
cmd: Command::Cancel { swap_id },
|
||||||
|
|
@ -113,6 +123,7 @@ where
|
||||||
}) => Arguments {
|
}) => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
|
trace,
|
||||||
config_path: config_path(config, testnet)?,
|
config_path: config_path(config, testnet)?,
|
||||||
env_config: env_config(testnet),
|
env_config: env_config(testnet),
|
||||||
cmd: Command::Refund { swap_id },
|
cmd: Command::Refund { swap_id },
|
||||||
|
|
@ -122,6 +133,7 @@ where
|
||||||
}) => Arguments {
|
}) => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
|
trace,
|
||||||
config_path: config_path(config, testnet)?,
|
config_path: config_path(config, testnet)?,
|
||||||
env_config: env_config(testnet),
|
env_config: env_config(testnet),
|
||||||
cmd: Command::Punish { swap_id },
|
cmd: Command::Punish { swap_id },
|
||||||
|
|
@ -129,6 +141,7 @@ where
|
||||||
RawCommand::ManualRecovery(ManualRecovery::SafelyAbort { swap_id }) => Arguments {
|
RawCommand::ManualRecovery(ManualRecovery::SafelyAbort { swap_id }) => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
|
trace,
|
||||||
config_path: config_path(config, testnet)?,
|
config_path: config_path(config, testnet)?,
|
||||||
env_config: env_config(testnet),
|
env_config: env_config(testnet),
|
||||||
cmd: Command::SafelyAbort { swap_id },
|
cmd: Command::SafelyAbort { swap_id },
|
||||||
|
|
@ -171,6 +184,7 @@ pub struct BitcoinAddressNetworkMismatch {
|
||||||
pub struct Arguments {
|
pub struct Arguments {
|
||||||
pub testnet: bool,
|
pub testnet: bool,
|
||||||
pub json: bool,
|
pub json: bool,
|
||||||
|
pub trace: bool,
|
||||||
pub config_path: PathBuf,
|
pub config_path: PathBuf,
|
||||||
pub env_config: env::Config,
|
pub env_config: env::Config,
|
||||||
pub cmd: Command,
|
pub cmd: Command,
|
||||||
|
|
@ -232,6 +246,9 @@ pub struct RawArguments {
|
||||||
)]
|
)]
|
||||||
pub json: bool,
|
pub json: bool,
|
||||||
|
|
||||||
|
#[structopt(long = "trace", help = "Also output verbose tracing logs to stdout")]
|
||||||
|
pub trace: bool,
|
||||||
|
|
||||||
#[structopt(
|
#[structopt(
|
||||||
short,
|
short,
|
||||||
long = "disable-timestamp",
|
long = "disable-timestamp",
|
||||||
|
|
@ -381,6 +398,7 @@ mod tests {
|
||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: false,
|
testnet: false,
|
||||||
json: false,
|
json: false,
|
||||||
|
trace: false,
|
||||||
config_path: default_mainnet_conf_path,
|
config_path: default_mainnet_conf_path,
|
||||||
env_config: mainnet_env_config,
|
env_config: mainnet_env_config,
|
||||||
cmd: Command::Start { resume_only: false },
|
cmd: Command::Start { resume_only: false },
|
||||||
|
|
@ -398,6 +416,7 @@ mod tests {
|
||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: false,
|
testnet: false,
|
||||||
json: false,
|
json: false,
|
||||||
|
trace: false,
|
||||||
config_path: default_mainnet_conf_path,
|
config_path: default_mainnet_conf_path,
|
||||||
env_config: mainnet_env_config,
|
env_config: mainnet_env_config,
|
||||||
cmd: Command::History {
|
cmd: Command::History {
|
||||||
|
|
@ -417,6 +436,7 @@ mod tests {
|
||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: false,
|
testnet: false,
|
||||||
json: false,
|
json: false,
|
||||||
|
trace: false,
|
||||||
config_path: default_mainnet_conf_path,
|
config_path: default_mainnet_conf_path,
|
||||||
env_config: mainnet_env_config,
|
env_config: mainnet_env_config,
|
||||||
cmd: Command::Balance,
|
cmd: Command::Balance,
|
||||||
|
|
@ -438,6 +458,7 @@ mod tests {
|
||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: false,
|
testnet: false,
|
||||||
json: false,
|
json: false,
|
||||||
|
trace: false,
|
||||||
config_path: default_mainnet_conf_path,
|
config_path: default_mainnet_conf_path,
|
||||||
env_config: mainnet_env_config,
|
env_config: mainnet_env_config,
|
||||||
cmd: Command::WithdrawBtc {
|
cmd: Command::WithdrawBtc {
|
||||||
|
|
@ -465,6 +486,7 @@ mod tests {
|
||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: false,
|
testnet: false,
|
||||||
json: false,
|
json: false,
|
||||||
|
trace: false,
|
||||||
config_path: default_mainnet_conf_path,
|
config_path: default_mainnet_conf_path,
|
||||||
env_config: mainnet_env_config,
|
env_config: mainnet_env_config,
|
||||||
cmd: Command::Cancel {
|
cmd: Command::Cancel {
|
||||||
|
|
@ -490,6 +512,7 @@ mod tests {
|
||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: false,
|
testnet: false,
|
||||||
json: false,
|
json: false,
|
||||||
|
trace: false,
|
||||||
config_path: default_mainnet_conf_path,
|
config_path: default_mainnet_conf_path,
|
||||||
env_config: mainnet_env_config,
|
env_config: mainnet_env_config,
|
||||||
cmd: Command::Refund {
|
cmd: Command::Refund {
|
||||||
|
|
@ -515,6 +538,7 @@ mod tests {
|
||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: false,
|
testnet: false,
|
||||||
json: false,
|
json: false,
|
||||||
|
trace: false,
|
||||||
config_path: default_mainnet_conf_path,
|
config_path: default_mainnet_conf_path,
|
||||||
env_config: mainnet_env_config,
|
env_config: mainnet_env_config,
|
||||||
cmd: Command::Punish {
|
cmd: Command::Punish {
|
||||||
|
|
@ -540,6 +564,7 @@ mod tests {
|
||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: false,
|
testnet: false,
|
||||||
json: false,
|
json: false,
|
||||||
|
trace: false,
|
||||||
config_path: default_mainnet_conf_path,
|
config_path: default_mainnet_conf_path,
|
||||||
env_config: mainnet_env_config,
|
env_config: mainnet_env_config,
|
||||||
cmd: Command::SafelyAbort {
|
cmd: Command::SafelyAbort {
|
||||||
|
|
@ -559,6 +584,7 @@ mod tests {
|
||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: true,
|
testnet: true,
|
||||||
json: false,
|
json: false,
|
||||||
|
trace: false,
|
||||||
config_path: default_testnet_conf_path,
|
config_path: default_testnet_conf_path,
|
||||||
env_config: testnet_env_config,
|
env_config: testnet_env_config,
|
||||||
cmd: Command::Start { resume_only: false },
|
cmd: Command::Start { resume_only: false },
|
||||||
|
|
@ -576,6 +602,7 @@ mod tests {
|
||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: true,
|
testnet: true,
|
||||||
json: false,
|
json: false,
|
||||||
|
trace: false,
|
||||||
config_path: default_testnet_conf_path,
|
config_path: default_testnet_conf_path,
|
||||||
env_config: testnet_env_config,
|
env_config: testnet_env_config,
|
||||||
cmd: Command::History {
|
cmd: Command::History {
|
||||||
|
|
@ -595,6 +622,7 @@ mod tests {
|
||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: true,
|
testnet: true,
|
||||||
json: false,
|
json: false,
|
||||||
|
trace: false,
|
||||||
config_path: default_testnet_conf_path,
|
config_path: default_testnet_conf_path,
|
||||||
env_config: testnet_env_config,
|
env_config: testnet_env_config,
|
||||||
cmd: Command::Balance,
|
cmd: Command::Balance,
|
||||||
|
|
@ -618,6 +646,7 @@ mod tests {
|
||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: true,
|
testnet: true,
|
||||||
json: false,
|
json: false,
|
||||||
|
trace: false,
|
||||||
config_path: default_testnet_conf_path,
|
config_path: default_testnet_conf_path,
|
||||||
env_config: testnet_env_config,
|
env_config: testnet_env_config,
|
||||||
cmd: Command::WithdrawBtc {
|
cmd: Command::WithdrawBtc {
|
||||||
|
|
@ -645,6 +674,7 @@ mod tests {
|
||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: true,
|
testnet: true,
|
||||||
json: false,
|
json: false,
|
||||||
|
trace: false,
|
||||||
config_path: default_testnet_conf_path,
|
config_path: default_testnet_conf_path,
|
||||||
env_config: testnet_env_config,
|
env_config: testnet_env_config,
|
||||||
cmd: Command::Cancel {
|
cmd: Command::Cancel {
|
||||||
|
|
@ -671,6 +701,7 @@ mod tests {
|
||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: true,
|
testnet: true,
|
||||||
json: false,
|
json: false,
|
||||||
|
trace: false,
|
||||||
config_path: default_testnet_conf_path,
|
config_path: default_testnet_conf_path,
|
||||||
env_config: testnet_env_config,
|
env_config: testnet_env_config,
|
||||||
cmd: Command::Refund {
|
cmd: Command::Refund {
|
||||||
|
|
@ -697,6 +728,7 @@ mod tests {
|
||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: true,
|
testnet: true,
|
||||||
json: false,
|
json: false,
|
||||||
|
trace: false,
|
||||||
config_path: default_testnet_conf_path,
|
config_path: default_testnet_conf_path,
|
||||||
env_config: testnet_env_config,
|
env_config: testnet_env_config,
|
||||||
cmd: Command::Punish {
|
cmd: Command::Punish {
|
||||||
|
|
@ -723,6 +755,7 @@ mod tests {
|
||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: true,
|
testnet: true,
|
||||||
json: false,
|
json: false,
|
||||||
|
trace: false,
|
||||||
config_path: default_testnet_conf_path,
|
config_path: default_testnet_conf_path,
|
||||||
env_config: testnet_env_config,
|
env_config: testnet_env_config,
|
||||||
cmd: Command::SafelyAbort {
|
cmd: Command::SafelyAbort {
|
||||||
|
|
@ -742,6 +775,25 @@ mod tests {
|
||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: false,
|
testnet: false,
|
||||||
json: false,
|
json: false,
|
||||||
|
trace: false,
|
||||||
|
config_path: default_mainnet_conf_path,
|
||||||
|
env_config: mainnet_env_config,
|
||||||
|
cmd: Command::Start { resume_only: false },
|
||||||
|
};
|
||||||
|
let args = parse_args(raw_ars).unwrap();
|
||||||
|
assert_eq!(expected_args, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ensure_trace_mapping() {
|
||||||
|
let default_mainnet_conf_path = env::Mainnet::getConfigFileDefaults().unwrap().config_path;
|
||||||
|
let mainnet_env_config = env::Mainnet::get_config();
|
||||||
|
|
||||||
|
let raw_ars = vec![BINARY_NAME, "--trace", "start"];
|
||||||
|
let expected_args = Arguments {
|
||||||
|
testnet: false,
|
||||||
|
json: false,
|
||||||
|
trace: true,
|
||||||
config_path: default_mainnet_conf_path,
|
config_path: default_mainnet_conf_path,
|
||||||
env_config: mainnet_env_config,
|
env_config: mainnet_env_config,
|
||||||
cmd: Command::Start { resume_only: false },
|
cmd: Command::Start { resume_only: false },
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ pub async fn main() -> Result<()> {
|
||||||
let Arguments {
|
let Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
|
trace,
|
||||||
config_path,
|
config_path,
|
||||||
env_config,
|
env_config,
|
||||||
cmd,
|
cmd,
|
||||||
|
|
@ -84,7 +85,7 @@ pub async fn main() -> Result<()> {
|
||||||
// Initialize tracing
|
// Initialize tracing
|
||||||
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)
|
common::tracing_util::init(LevelFilter::DEBUG, format, log_dir, None, trace)
|
||||||
.expect("initialize tracing");
|
.expect("initialize tracing");
|
||||||
tracing::info!(
|
tracing::info!(
|
||||||
binary = "asb",
|
binary = "asb",
|
||||||
|
|
|
||||||
|
|
@ -299,6 +299,7 @@ impl ContextBuilder {
|
||||||
format,
|
format,
|
||||||
data_dir.join("logs"),
|
data_dir.join("logs"),
|
||||||
self.tauri_handle.clone(),
|
self.tauri_handle.clone(),
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
tracing::info!(
|
tracing::info!(
|
||||||
binary = "cli",
|
binary = "cli",
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,14 @@ pub enum Format {
|
||||||
/// Initialize tracing and enable logging messages according to these options.
|
/// Initialize tracing and enable logging messages according to these options.
|
||||||
/// Besides printing to `stdout`, this will append to a log file.
|
/// Besides printing to `stdout`, this will append to a log file.
|
||||||
/// Said file will contain JSON-formatted logs of all levels,
|
/// Said file will contain JSON-formatted logs of all levels,
|
||||||
/// disregarding the arguments to this function.
|
/// disregarding the arguments to this function. When `trace_stdout` is `true`,
|
||||||
|
/// all tracing logs are also emitted to stdout.
|
||||||
pub fn init(
|
pub fn init(
|
||||||
level_filter: LevelFilter,
|
level_filter: LevelFilter,
|
||||||
format: Format,
|
format: Format,
|
||||||
dir: impl AsRef<Path>,
|
dir: impl AsRef<Path>,
|
||||||
tauri_handle: Option<TauriHandle>,
|
tauri_handle: Option<TauriHandle>,
|
||||||
|
trace_stdout: bool,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let ALL_CRATES: Vec<&str> = vec![
|
let ALL_CRATES: Vec<&str> = vec![
|
||||||
"swap",
|
"swap",
|
||||||
|
|
@ -95,23 +97,29 @@ pub fn init(
|
||||||
.json()
|
.json()
|
||||||
.with_filter(env_filter(level_filter, ALL_CRATES.clone())?);
|
.with_filter(env_filter(level_filter, ALL_CRATES.clone())?);
|
||||||
|
|
||||||
// We only log the bare minimum to the terminal
|
// If trace_stdout is true, we log all messages to the terminal
|
||||||
// Crates: swap, asb
|
// Otherwise, we only log the bare minimum
|
||||||
// Level: Passed in
|
let terminal_layer_env_filter = match trace_stdout {
|
||||||
let env_filtered = env_filter(level_filter, OUR_CRATES.clone())?;
|
true => env_filter(LevelFilter::TRACE, ALL_CRATES.clone())?,
|
||||||
|
false => env_filter(level_filter, OUR_CRATES.clone())?,
|
||||||
// Apply the environment filter and box the layer for the terminal
|
};
|
||||||
let final_terminal_layer = match format {
|
let final_terminal_layer = match format {
|
||||||
Format::Json => terminal_layer.json().with_filter(env_filtered).boxed(),
|
Format::Json => terminal_layer
|
||||||
Format::Raw => terminal_layer.with_filter(env_filtered).boxed(),
|
.json()
|
||||||
|
.with_filter(terminal_layer_env_filter)
|
||||||
|
.boxed(),
|
||||||
|
Format::Raw => terminal_layer
|
||||||
|
.with_filter(terminal_layer_env_filter)
|
||||||
|
.boxed(),
|
||||||
};
|
};
|
||||||
|
|
||||||
tracing_subscriber::registry()
|
let subscriber = tracing_subscriber::registry()
|
||||||
.with(file_layer)
|
.with(file_layer)
|
||||||
.with(tracing_file_layer)
|
.with(tracing_file_layer)
|
||||||
.with(final_terminal_layer)
|
.with(final_terminal_layer)
|
||||||
.with(tauri_layer)
|
.with(tauri_layer);
|
||||||
.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!(%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");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue