diff --git a/bin/src/cli_args.rs b/bin/src/cli_args.rs index e8a0f19..a5b224f 100644 --- a/bin/src/cli_args.rs +++ b/bin/src/cli_args.rs @@ -23,4 +23,9 @@ pub struct CliArgs { /// If not provided the language will try to be inferred by the extension of the base file. #[arg(long)] pub(crate) language: Option, + + /// The log level provided for the execution. + /// If not provided defaults to INFO. + #[arg(long)] + pub(crate) log_level: Option, } diff --git a/bin/src/control.rs b/bin/src/control.rs index 0c5adbc..600fee5 100644 --- a/bin/src/control.rs +++ b/bin/src/control.rs @@ -58,21 +58,34 @@ pub fn run_tool_on_merge_scenario( let parser_configuration = ParserConfiguration::from(language); + log::info!("Started parsing base file"); let base_tree = parsing::parse_string(base, &parser_configuration).map_err(ExecutionError::ParsingError)?; + log::info!("Finished parsing base file"); + log::info!("Started parsing left file"); let left_tree = parsing::parse_string(left, &parser_configuration).map_err(ExecutionError::ParsingError)?; + log::info!("Finished parsing left file"); + log::info!("Started parsing right file"); let right_tree = parsing::parse_string(right, &parser_configuration) .map_err(ExecutionError::ParsingError)?; + log::info!("Finished parsing right file"); let matching_configuration = matching_configuration::MatchingConfiguration::from(language); + log::info!("Started calculation of matchings between left and base"); let matchings_left_base = matching::calculate_matchings(&left_tree, &base_tree, &matching_configuration); + log::info!("Finished calculation of matchings between left and base"); + log::info!("Started calculation of matchings between right and base"); let matchings_right_base = matching::calculate_matchings(&right_tree, &base_tree, &matching_configuration); + log::info!("Finished calculation of matchings between right and base"); + log::info!("Started calculation of matchings between left and right"); let matchings_left_right = matching::calculate_matchings(&left_tree, &right_tree, &matching_configuration); + log::info!("Finished calculation of matchings between left and right"); + log::info!("Starting merge of the trees"); let result = merge::merge( &base_tree, &left_tree, @@ -82,6 +95,7 @@ pub fn run_tool_on_merge_scenario( &matchings_left_right, ) .map_err(ExecutionError::MergeError)?; + log::info!("Finished merge of the trees"); match result.has_conflict() { true => Ok(ExecutionResult::WithConflicts(result.to_string())), diff --git a/bin/src/main.rs b/bin/src/main.rs index 199a472..be48789 100644 --- a/bin/src/main.rs +++ b/bin/src/main.rs @@ -6,9 +6,11 @@ mod language; use clap::Parser; fn main() { - env_logger::init(); - let args = cli_args::CliArgs::parse(); + env_logger::builder().filter_level(args.log_level.unwrap_or(log::LevelFilter::Info)).init(); + + log::info!("Starting Generic Merge tool execution"); + log::debug!("Parsed arguments: {:?}", args); let base = std::fs::read_to_string(&args.base_path).unwrap_or_else(|error| { log::error!("Error while reading base file: {}", error);