Skip to content

Commit 6a58eb2

Browse files
committed
Make log creation be configurable
For now each latte usage creates a log file. And frequent small usages make it generate a lot of garbage log files. So, make it's creation be configurable and disable it by default.
1 parent 558cd49 commit 6a58eb2

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/config.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ pub struct RunCommand {
490490
#[clap(long("tag"), value_delimiter = ',')]
491491
pub tags: Vec<String>,
492492

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

709+
/// Whether to create log file and write to it or not.
710+
#[clap(long("enable-logging"), required = false)]
711+
pub enable_logging: bool,
712+
709713
#[clap(subcommand)]
710714
pub command: Command,
711715
}

src/main.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -563,12 +563,16 @@ fn run_id() -> String {
563563
fn main() {
564564
let run_id = run_id();
565565
let config = AppConfig::parse();
566-
let _guard = match setup_logging(run_id.as_str(), &config) {
567-
Ok(guard) => guard,
568-
Err(e) => {
569-
eprintln!("error: {e}");
570-
exit(1);
566+
let _guard = if config.enable_logging {
567+
match setup_logging(run_id.as_str(), &config) {
568+
Ok(guard) => Some(guard),
569+
Err(e) => {
570+
eprintln!("error: {e}");
571+
exit(1);
572+
}
571573
}
574+
} else {
575+
None
572576
};
573577

574578
let command = config.command;

0 commit comments

Comments
 (0)