mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Timestamp logs by default on the ASB
Disable timestamps using the command line flag
This commit is contained in:
parent
e380052610
commit
ee6524a75f
@ -9,12 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Timestamping can now be enabled using the `timestamp` command line argument to the ASB.
|
- Timestamping is now enabled by default even when the ASB is not run inside an interactive terminal.
|
||||||
JSON logs and ASB output in an interactive terminal are no longer timestamped by default.
|
|
||||||
- The `cancel`, `refund` and `punish` subcommands in ASB and CLI are run with the `--force` by default and the `--force` option has been removed.
|
- The `cancel`, `refund` and `punish` subcommands in ASB and CLI are run with the `--force` by default and the `--force` option has been removed.
|
||||||
The force flag was used to ignore blockheight and protocol state checks.
|
The force flag was used to ignore blockheight and protocol state checks.
|
||||||
Users can still restart a swap with these checks using the `resume` subcommand.
|
Users can still restart a swap with these checks using the `resume` subcommand.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added a `disable-timestamp` flag to the ASB that disables timestamps from logs.
|
||||||
|
|
||||||
## [0.8.3] - 2021-09-03
|
## [0.8.3] - 2021-09-03
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@ -19,7 +19,7 @@ where
|
|||||||
let args = RawArguments::from_clap(&matches);
|
let args = RawArguments::from_clap(&matches);
|
||||||
|
|
||||||
let json = args.json;
|
let json = args.json;
|
||||||
let timestamp = args.timestamp;
|
let disable_timestamp = args.disable_timestamp;
|
||||||
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,7 +28,7 @@ where
|
|||||||
RawCommand::Start { resume_only } => Arguments {
|
RawCommand::Start { resume_only } => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
timestamp,
|
disable_timestamp,
|
||||||
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 },
|
||||||
@ -36,7 +36,7 @@ where
|
|||||||
RawCommand::History => Arguments {
|
RawCommand::History => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
timestamp,
|
disable_timestamp,
|
||||||
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,
|
cmd: Command::History,
|
||||||
@ -44,7 +44,7 @@ where
|
|||||||
RawCommand::WithdrawBtc { amount, address } => Arguments {
|
RawCommand::WithdrawBtc { amount, address } => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
timestamp,
|
disable_timestamp,
|
||||||
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 {
|
||||||
@ -55,7 +55,7 @@ where
|
|||||||
RawCommand::Balance => Arguments {
|
RawCommand::Balance => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
timestamp,
|
disable_timestamp,
|
||||||
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,
|
||||||
@ -66,7 +66,7 @@ where
|
|||||||
}) => Arguments {
|
}) => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
timestamp,
|
disable_timestamp,
|
||||||
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 {
|
||||||
@ -80,7 +80,7 @@ where
|
|||||||
}) => Arguments {
|
}) => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
timestamp,
|
disable_timestamp,
|
||||||
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 },
|
||||||
@ -90,7 +90,7 @@ where
|
|||||||
}) => Arguments {
|
}) => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
timestamp,
|
disable_timestamp,
|
||||||
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 },
|
||||||
@ -100,7 +100,7 @@ where
|
|||||||
}) => Arguments {
|
}) => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
timestamp,
|
disable_timestamp,
|
||||||
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 },
|
||||||
@ -108,7 +108,7 @@ where
|
|||||||
RawCommand::ManualRecovery(ManualRecovery::SafelyAbort { swap_id }) => Arguments {
|
RawCommand::ManualRecovery(ManualRecovery::SafelyAbort { swap_id }) => Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
timestamp,
|
disable_timestamp,
|
||||||
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 },
|
||||||
@ -168,7 +168,7 @@ pub struct BitcoinAddressNetworkMismatch {
|
|||||||
pub struct Arguments {
|
pub struct Arguments {
|
||||||
pub testnet: bool,
|
pub testnet: bool,
|
||||||
pub json: bool,
|
pub json: bool,
|
||||||
pub timestamp: bool,
|
pub disable_timestamp: 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,
|
||||||
@ -223,10 +223,10 @@ pub struct RawArguments {
|
|||||||
|
|
||||||
#[structopt(
|
#[structopt(
|
||||||
short,
|
short,
|
||||||
long = "timestamp",
|
long = "disable-timestamp",
|
||||||
help = "Adds a timestamp to the log messages"
|
help = "Disable timestamping of log messages"
|
||||||
)]
|
)]
|
||||||
pub timestamp: bool,
|
pub disable_timestamp: bool,
|
||||||
|
|
||||||
#[structopt(
|
#[structopt(
|
||||||
long = "config",
|
long = "config",
|
||||||
@ -344,7 +344,7 @@ mod tests {
|
|||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: false,
|
testnet: false,
|
||||||
json: false,
|
json: false,
|
||||||
timestamp: false,
|
disable_timestamp: 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 },
|
||||||
@ -362,7 +362,7 @@ mod tests {
|
|||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: false,
|
testnet: false,
|
||||||
json: false,
|
json: false,
|
||||||
timestamp: false,
|
disable_timestamp: 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,
|
||||||
@ -380,7 +380,7 @@ mod tests {
|
|||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: false,
|
testnet: false,
|
||||||
json: false,
|
json: false,
|
||||||
timestamp: false,
|
disable_timestamp: 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,
|
||||||
@ -402,7 +402,7 @@ mod tests {
|
|||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: false,
|
testnet: false,
|
||||||
json: false,
|
json: false,
|
||||||
timestamp: false,
|
disable_timestamp: 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 {
|
||||||
@ -429,7 +429,7 @@ mod tests {
|
|||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: false,
|
testnet: false,
|
||||||
json: false,
|
json: false,
|
||||||
timestamp: false,
|
disable_timestamp: 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 {
|
||||||
@ -455,7 +455,7 @@ mod tests {
|
|||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: false,
|
testnet: false,
|
||||||
json: false,
|
json: false,
|
||||||
timestamp: false,
|
disable_timestamp: 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 {
|
||||||
@ -481,7 +481,7 @@ mod tests {
|
|||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: false,
|
testnet: false,
|
||||||
json: false,
|
json: false,
|
||||||
timestamp: false,
|
disable_timestamp: 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 {
|
||||||
@ -507,7 +507,7 @@ mod tests {
|
|||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: false,
|
testnet: false,
|
||||||
json: false,
|
json: false,
|
||||||
timestamp: false,
|
disable_timestamp: 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 {
|
||||||
@ -527,7 +527,7 @@ mod tests {
|
|||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: true,
|
testnet: true,
|
||||||
json: false,
|
json: false,
|
||||||
timestamp: false,
|
disable_timestamp: 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 },
|
||||||
@ -545,7 +545,7 @@ mod tests {
|
|||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: true,
|
testnet: true,
|
||||||
json: false,
|
json: false,
|
||||||
timestamp: false,
|
disable_timestamp: 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,
|
||||||
@ -563,7 +563,7 @@ mod tests {
|
|||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: true,
|
testnet: true,
|
||||||
json: false,
|
json: false,
|
||||||
timestamp: false,
|
disable_timestamp: 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,
|
||||||
@ -587,7 +587,7 @@ mod tests {
|
|||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: true,
|
testnet: true,
|
||||||
json: false,
|
json: false,
|
||||||
timestamp: false,
|
disable_timestamp: 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 {
|
||||||
@ -614,7 +614,7 @@ mod tests {
|
|||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: true,
|
testnet: true,
|
||||||
json: false,
|
json: false,
|
||||||
timestamp: false,
|
disable_timestamp: 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 {
|
||||||
@ -641,7 +641,7 @@ mod tests {
|
|||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: true,
|
testnet: true,
|
||||||
json: false,
|
json: false,
|
||||||
timestamp: false,
|
disable_timestamp: 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 {
|
||||||
@ -668,7 +668,7 @@ mod tests {
|
|||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: true,
|
testnet: true,
|
||||||
json: false,
|
json: false,
|
||||||
timestamp: false,
|
disable_timestamp: 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 {
|
||||||
@ -695,7 +695,7 @@ mod tests {
|
|||||||
let expected_args = Arguments {
|
let expected_args = Arguments {
|
||||||
testnet: true,
|
testnet: true,
|
||||||
json: false,
|
json: false,
|
||||||
timestamp: false,
|
disable_timestamp: 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 {
|
||||||
@ -706,6 +706,24 @@ mod tests {
|
|||||||
assert_eq!(expected_args, args);
|
assert_eq!(expected_args, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ensure_disable_timestamp_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, "--disable-timestamp", "start"];
|
||||||
|
let expected_args = Arguments {
|
||||||
|
testnet: false,
|
||||||
|
json: false,
|
||||||
|
disable_timestamp: true,
|
||||||
|
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]
|
#[test]
|
||||||
fn given_user_provides_config_path_then_no_default_config_path_returned() {
|
fn given_user_provides_config_path_then_no_default_config_path_returned() {
|
||||||
let cp = PathBuf::from_str("/some/config/path").unwrap();
|
let cp = PathBuf::from_str("/some/config/path").unwrap();
|
||||||
|
@ -45,7 +45,7 @@ async fn main() -> Result<()> {
|
|||||||
let Arguments {
|
let Arguments {
|
||||||
testnet,
|
testnet,
|
||||||
json,
|
json,
|
||||||
timestamp,
|
disable_timestamp,
|
||||||
config_path,
|
config_path,
|
||||||
env_config,
|
env_config,
|
||||||
cmd,
|
cmd,
|
||||||
@ -67,7 +67,7 @@ async fn main() -> Result<()> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
asb::tracing::init(LevelFilter::DEBUG, json, timestamp).expect("initialize tracing");
|
asb::tracing::init(LevelFilter::DEBUG, json, !disable_timestamp).expect("initialize tracing");
|
||||||
|
|
||||||
let config = match read_config(config_path.clone())? {
|
let config = match read_config(config_path.clone())? {
|
||||||
Ok(config) => config,
|
Ok(config) => config,
|
||||||
|
Loading…
Reference in New Issue
Block a user