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

[rust] Use DEBUG level for WARN traces in offline mode #13810

Merged
merged 1 commit into from
Apr 12, 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
11 changes: 7 additions & 4 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -938,10 +938,13 @@ pub trait SeleniumManager {
.unwrap_or_default()
.unwrap_or_default();
if best_browser_from_cache.exists() {
self.get_logger().warn(format!(
"There was an error managing {}; using browser found in the cache",
self.get_browser_name()
));
self.get_logger().debug_or_warn(
format!(
"There was an error managing {}; using browser found in the cache",
self.get_browser_name()
),
self.is_offline(),
);
browser_path = path_to_string(best_browser_from_cache);
}
}
Expand Down
5 changes: 5 additions & 0 deletions rust/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ impl Logger {
self.logger(message.to_string(), Level::Debug);
}

pub fn debug_or_warn<T: Display>(&self, message: T, is_debug: bool) {
let level = if is_debug { Level::Debug } else { Level::Warn };
self.logger(message.to_string(), level);
}

pub fn trace<T: Display>(&self, message: T) {
self.logger(message.to_string(), Level::Trace);
}
Expand Down
13 changes: 8 additions & 5 deletions rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,14 @@ fn main() {
if let Some(best_driver_from_cache) =
selenium_manager.find_best_driver_from_cache().unwrap()
{
log.warn(format!(
"There was an error managing {} ({}); using driver found in the cache",
selenium_manager.get_driver_name(),
err
));
log.debug_or_warn(
format!(
"There was an error managing {} ({}); using driver found in the cache",
selenium_manager.get_driver_name(),
err
),
selenium_manager.is_offline(),
);
log_driver_and_browser_path(
log,
&best_driver_from_cache,
Expand Down