mirror of
https://github.com/TrueLayer/reqwest-middleware.git
synced 2024-12-25 18:36:30 +00:00
Fix empty and different level naming
This commit is contained in:
parent
4ea0e42bcd
commit
d966ad89e5
1 changed files with 12 additions and 0 deletions
|
@ -22,6 +22,7 @@ use ::log as LogTracing;
|
|||
#[doc(hidden)]
|
||||
// We need this macro because tracing expects the level to be const:
|
||||
// https://github.com/tokio-rs/tracing/issues/2730
|
||||
#[cfg(feature = "tracing")]
|
||||
macro_rules! log_retry {
|
||||
($level:expr, $($args:tt)*) => {{
|
||||
match $level {
|
||||
|
@ -34,6 +35,13 @@ macro_rules! log_retry {
|
|||
}};
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "log", not(feature = "tracing")))]
|
||||
macro_rules! log_retry {
|
||||
($level:expr, $($args:tt)*) => {{
|
||||
LogTracing::log!($level, $($args)*)
|
||||
}};
|
||||
}
|
||||
|
||||
/// `RetryTransientMiddleware` offers retry logic for requests that fail in a transient manner
|
||||
/// and can be safely executed again.
|
||||
///
|
||||
|
@ -108,7 +116,10 @@ where
|
|||
Self {
|
||||
retry_policy,
|
||||
retryable_strategy,
|
||||
#[cfg(feature = "tracing")]
|
||||
retry_log_level: LogLevel::WARN,
|
||||
#[cfg(all(feature = "log", not(feature = "tracing")))]
|
||||
retry_log_level: LogLevel::Warn,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -175,6 +186,7 @@ where
|
|||
.duration_since(SystemTime::now())
|
||||
.unwrap_or_else(|_| Duration::default());
|
||||
// Sleep the requested amount before we try again.
|
||||
#[cfg(any(feature = "log", feature = "tracing"))]
|
||||
log_retry!(
|
||||
self.retry_log_level,
|
||||
"Retry attempt #{}. Sleeping {:?} before the next attempt",
|
||||
|
|
Loading…
Reference in a new issue