Skip to content

Commit

Permalink
don't build progress bar if log level > info
Browse files Browse the repository at this point in the history
  • Loading branch information
robfitzgerald committed Dec 20, 2024
1 parent da5f4f0 commit 6d46483
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions rust/routee-compass-core/src/util/fs/read_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ pub fn from_csv<'a, T>(
where
T: serde::de::DeserializeOwned + 'a,
{
let bar_opt = progress.and_then(|b| b.build().ok());
// build the progress bar if the user provided it and the logging system is at least INFO
let bar_opt = if log::log_enabled!(log::Level::Info) {
progress.and_then(|b| b.build().ok())
} else {
None
};

let row_callback: CsvCallback<'a, T> = match (callback, bar_opt) {
(None, None) => None,
Expand Down Expand Up @@ -95,7 +100,12 @@ pub fn read_raw_file<F, T>(
where
F: AsRef<Path>,
{
let bar_opt = progress.and_then(|b| b.build().ok());
// build the progress bar if the user provided it and the logging system is at least INFO
let bar_opt = if log::log_enabled!(log::Level::Info) {
progress.and_then(|b| b.build().ok())
} else {
None
};

let row_callback: RawCallback = match (callback, bar_opt) {
(None, None) => None,
Expand Down

0 comments on commit 6d46483

Please sign in to comment.