diff options
author | notgne2 | 2021-01-10 23:44:22 -0700 |
---|---|---|
committer | notgne2 | 2021-01-10 23:44:22 -0700 |
commit | 4300218fc791f51c3fdd4677eae9dad1dabb3550 (patch) | |
tree | 68eda894ef1c56355c47f6e0ea91516566d43f57 /src/main.rs | |
parent | 330a73e329caa1c1b320b67b1b35fb5448223a31 (diff) | |
parent | aa42daa8002f17c33a0a56abc110ca1bc14e8cc2 (diff) |
Merge branch 'master' into notgne2/fix-systemd-boot-entry
Diffstat (limited to '')
-rw-r--r-- | src/main.rs | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs index be7ad40..1544fed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,8 +12,6 @@ use tokio::process::Command; use thiserror::Error; -extern crate pretty_env_logger; - #[macro_use] extern crate log; @@ -39,6 +37,13 @@ struct Opts { /// Extra arguments to be passed to nix build extra_build_args: Vec<String>, + /// Print debug logs to output + #[clap(short, long)] + debug_logs: bool, + /// Directory to print logs to (including the background activation process) + #[clap(long)] + log_dir: Option<String>, + /// Keep the build outputs of each built profile #[clap(short, long)] keep_result: bool, @@ -242,7 +247,7 @@ fn print_deployment( let toml = toml::to_string(&part_map)?; - warn!("The following profiles are going to be deployed:\n{}", toml); + info!("The following profiles are going to be deployed:\n{}", toml); Ok(()) } @@ -336,6 +341,8 @@ async fn run_deploy( keep_result: bool, result_path: Option<&str>, extra_build_args: &[String], + debug_logs: bool, + log_dir: Option<String>, ) -> Result<(), RunDeployError> { let to_deploy: Vec<((&str, &utils::data::Node), (&str, &utils::data::Profile))> = match (&deploy_flake.node, &deploy_flake.profile) { @@ -432,6 +439,8 @@ async fn run_deploy( profile, profile_name, &cmd_overrides, + debug_logs, + log_dir.as_deref(), ); let deploy_defs = deploy_data.defs()?; @@ -480,19 +489,21 @@ enum RunError { GetDeploymentDataError(#[from] GetDeploymentDataError), #[error("Error parsing flake: {0}")] ParseFlakeError(#[from] utils::ParseFlakeError), + #[error("Error initiating logger: {0}")] + LoggerError(#[from] flexi_logger::FlexiLoggerError), #[error("{0}")] RunDeployError(#[from] RunDeployError), } async fn run() -> Result<(), RunError> { - if std::env::var("DEPLOY_LOG").is_err() { - std::env::set_var("DEPLOY_LOG", "info"); - } - - pretty_env_logger::init_custom_env("DEPLOY_LOG"); - let opts: Opts = Opts::parse(); + utils::init_logger( + opts.debug_logs, + opts.log_dir.as_deref(), + utils::LoggerType::Deploy, + )?; + let deploy_flake = utils::parse_flake(opts.flake.as_str())?; let cmd_overrides = utils::CmdOverrides { @@ -534,6 +545,8 @@ async fn run() -> Result<(), RunError> { opts.keep_result, result_path, &opts.extra_build_args, + opts.debug_logs, + opts.log_dir, ) .await?; |