Add name argument
Gives more options to the user to customize logs Signed-off-by: Nicholas Mello <nick@nmello.dev>
This commit is contained in:
10
src/main.rs
10
src/main.rs
@@ -25,6 +25,9 @@ impl From<LogLevel> for Level {
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Args {
|
||||
#[arg(short, long)]
|
||||
name: Option<String>,
|
||||
|
||||
#[arg(short, long, default_value = "info")]
|
||||
log_level: LogLevel,
|
||||
|
||||
@@ -34,8 +37,13 @@ struct Args {
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
|
||||
let name = match args.name {
|
||||
Some(name) => name,
|
||||
None => "command-line".into(),
|
||||
};
|
||||
|
||||
// Initialize the logging system
|
||||
init_logging("command-line");
|
||||
init_logging(name.as_str());
|
||||
|
||||
log!(args.log_level.into(), "{}", args.print_string);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user