Skip to content

Commit 3cf0669

Browse files
authored
[rust] Use DEBUG level for WARN traces in offline mode (#13810)
1 parent 9ab4f75 commit 3cf0669

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

rust/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -938,10 +938,13 @@ pub trait SeleniumManager {
938938
.unwrap_or_default()
939939
.unwrap_or_default();
940940
if best_browser_from_cache.exists() {
941-
self.get_logger().warn(format!(
942-
"There was an error managing {}; using browser found in the cache",
943-
self.get_browser_name()
944-
));
941+
self.get_logger().debug_or_warn(
942+
format!(
943+
"There was an error managing {}; using browser found in the cache",
944+
self.get_browser_name()
945+
),
946+
self.is_offline(),
947+
);
945948
browser_path = path_to_string(best_browser_from_cache);
946949
}
947950
}

rust/src/logger.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ impl Logger {
150150
self.logger(message.to_string(), Level::Debug);
151151
}
152152

153+
pub fn debug_or_warn<T: Display>(&self, message: T, is_debug: bool) {
154+
let level = if is_debug { Level::Debug } else { Level::Warn };
155+
self.logger(message.to_string(), level);
156+
}
157+
153158
pub fn trace<T: Display>(&self, message: T) {
154159
self.logger(message.to_string(), Level::Trace);
155160
}

rust/src/main.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,14 @@ fn main() {
245245
if let Some(best_driver_from_cache) =
246246
selenium_manager.find_best_driver_from_cache().unwrap()
247247
{
248-
log.warn(format!(
249-
"There was an error managing {} ({}); using driver found in the cache",
250-
selenium_manager.get_driver_name(),
251-
err
252-
));
248+
log.debug_or_warn(
249+
format!(
250+
"There was an error managing {} ({}); using driver found in the cache",
251+
selenium_manager.get_driver_name(),
252+
err
253+
),
254+
selenium_manager.is_offline(),
255+
);
253256
log_driver_and_browser_path(
254257
log,
255258
&best_driver_from_cache,

0 commit comments

Comments
 (0)