Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make log creation be configurable #20

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ pub struct RunCommand {
#[clap(long("tag"), value_delimiter = ',')]
pub tags: Vec<String>,

/// Wether to generate final report or not. If disabled (default) then memory consumption will
/// Whether to generate final report or not. If disabled (default) then memory consumption will
/// be static, otherwise it will leak linearly storing samples info for a final report
/// calculation.
#[clap(long("generate-report"), required = false)]
Expand Down Expand Up @@ -706,6 +706,10 @@ pub struct AppConfig {
#[clap(long("log-dir"), env("LATTE_LOG_DIR"), default_value = ".")]
pub log_dir: PathBuf,

/// Whether to create log file and write to it or not.
#[clap(long("enable-logging"), required = false)]
pub enable_logging: bool,

#[clap(subcommand)]
pub command: Command,
}
Expand Down
14 changes: 9 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,12 +563,16 @@ fn run_id() -> String {
fn main() {
let run_id = run_id();
let config = AppConfig::parse();
let _guard = match setup_logging(run_id.as_str(), &config) {
Ok(guard) => guard,
Err(e) => {
eprintln!("error: {e}");
exit(1);
let _guard = if config.enable_logging {
match setup_logging(run_id.as_str(), &config) {
Ok(guard) => Some(guard),
Err(e) => {
eprintln!("error: {e}");
exit(1);
}
}
} else {
None
};

let command = config.command;
Expand Down
Loading