Add proper logging #9
@ -1,3 +1,5 @@
|
|||||||
|
use clap::ValueEnum;
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct Logger {
|
pub struct Logger {
|
||||||
pub level: LogLevel,
|
pub level: LogLevel,
|
||||||
@ -17,13 +19,13 @@ impl Logger {
|
|||||||
println!("{}", message.to_string());
|
println!("{}", message.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
define_log_function!(info, Info);
|
define_log_function!(info, Info);
|
||||||
define_log_function!(debug, Debug);
|
define_log_function!(debug, Debug);
|
||||||
define_log_function!(error, Error);
|
define_log_function!(error, Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default, ValueEnum)]
|
||||||
pub enum LogLevel {
|
pub enum LogLevel {
|
||||||
Debug,
|
Debug,
|
||||||
#[default]
|
#[default]
|
||||||
|
|||||||
11
src/main.rs
11
src/main.rs
@ -6,7 +6,7 @@ mod logger;
|
|||||||
|
|
||||||
use crate::action::{Action, FileAction, ServerActions};
|
use crate::action::{Action, FileAction, ServerActions};
|
||||||
use crate::file::{FileMatcher, FileNameInfo};
|
use crate::file::{FileMatcher, FileNameInfo};
|
||||||
use crate::logger::Logger;
|
use crate::logger::{LogLevel, Logger};
|
||||||
use crate::os_string_builder::ReplaceWithOsStr;
|
use crate::os_string_builder::ReplaceWithOsStr;
|
||||||
use clap::{Parser, Subcommand, ValueEnum};
|
use clap::{Parser, Subcommand, ValueEnum};
|
||||||
use lazy_regex::{lazy_regex, Lazy, Regex};
|
use lazy_regex::{lazy_regex, Lazy, Regex};
|
||||||
@ -43,6 +43,15 @@ struct Args {
|
|||||||
/// The ssh names and optionally home directories of the servers to perform the action on
|
/// The ssh names and optionally home directories of the servers to perform the action on
|
||||||
#[arg(num_args = 1.., value_parser = ServerReference::from_str)]
|
#[arg(num_args = 1.., value_parser = ServerReference::from_str)]
|
||||||
servers: Vec<ServerReference>,
|
servers: Vec<ServerReference>,
|
||||||
|
/// How verbose logging output should be
|
||||||
|
#[arg(long, conflicts_with_all = ["quiet", "info"], default_value = "info")]
|
||||||
|
log_level: Option<LogLevel>,
|
||||||
|
/// Only log errors
|
||||||
|
#[arg(short, long, default_value = "false")]
|
||||||
|
quiet: bool,
|
||||||
|
/// Log additional debugging info
|
||||||
|
#[arg(short='v', long, default_value = "false")]
|
||||||
|
info: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand, Debug)]
|
#[derive(Subcommand, Debug)]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user