pub struct AccessLogLayer {
pub log_success: bool,
pub include_ip: bool,
pub slow_threshold_ms: u64,
pub redact_query_params: Vec<String>,
}Expand description
Configuration for the access log middleware.
Fields§
§log_success: boolLog all requests including 1xx/2xx/3xx (default true). When false, only 4xx/5xx are logged — useful in production to keep volume down.
include_ip: boolInclude the client IP address in the event (requires
into_make_service_with_connect_info::<SocketAddr>()).
slow_threshold_ms: u64Threshold (in ms) above which a request is logged at WARN instead
of INFO. Set to u64::MAX to disable. Default 1000ms.
redact_query_params: Vec<String>Query parameter names whose values get redacted in logs. Default
includes the common credential-bearing params: password, token,
secret, api_key, access_token, refresh_token, signature.
Implementations§
Source§impl AccessLogLayer
impl AccessLogLayer
Sourcepub fn new() -> Self
pub fn new() -> Self
New layer with default config: log every request, include IP, flag requests >1000ms as slow, redact known credential query params.
Sourcepub fn redact(self, params: Vec<String>) -> Self
pub fn redact(self, params: Vec<String>) -> Self
Replace the redacted-params list with params. Pass an empty list
to disable redaction.
Sourcepub fn redact_additional(self, name: impl Into<String>) -> Self
pub fn redact_additional(self, name: impl Into<String>) -> Self
Add an additional query-param name to redact (extends defaults).
Sourcepub fn errors_only(self) -> Self
pub fn errors_only(self) -> Self
Skip 2xx/3xx responses; only log 4xx/5xx.
Sourcepub fn without_ip(self) -> Self
pub fn without_ip(self) -> Self
Don’t include the client IP in events.
Sourcepub fn slow_threshold_ms(self, ms: u64) -> Self
pub fn slow_threshold_ms(self, ms: u64) -> Self
Set the threshold (in ms) above which requests are logged at WARN.
Trait Implementations§
Source§impl Clone for AccessLogLayer
impl Clone for AccessLogLayer
Source§fn clone(&self) -> AccessLogLayer
fn clone(&self) -> AccessLogLayer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AccessLogLayer
impl RefUnwindSafe for AccessLogLayer
impl Send for AccessLogLayer
impl Sync for AccessLogLayer
impl Unpin for AccessLogLayer
impl UnsafeUnpin for AccessLogLayer
impl UnwindSafe for AccessLogLayer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more