aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authornotgne22020-12-27 10:48:18 -0700
committernotgne22020-12-27 10:52:37 -0700
commit4461d1ea3f494778f07041164f6b8a252bd26ea2 (patch)
tree85fc2196e5c6869947c5f2d92713ac2b3bde8e2b /src/main.rs
parent91e934fd9e1e06044f75a3e3ad998813c2a90fb5 (diff)
Replace logger, add more logging options including files
Diffstat (limited to '')
-rw-r--r--src/main.rs25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs
index be7ad40..c003da7 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,
@@ -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,17 @@ 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(), false)?;
+
let deploy_flake = utils::parse_flake(opts.flake.as_str())?;
let cmd_overrides = utils::CmdOverrides {
@@ -534,6 +541,8 @@ async fn run() -> Result<(), RunError> {
opts.keep_result,
result_path,
&opts.extra_build_args,
+ opts.debug_logs,
+ opts.log_dir,
)
.await?;