Skip to content

Commit

Permalink
update new method for status filter in log middleware, add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Aug 22, 2023
1 parent 8419ac1 commit 2392c53
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion actix-web/src/middleware/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,17 @@ impl Logger {
}

/// Set a range of status to include in the logging
pub fn status_range<R: RangeBounds<StatusCode>>(mut self, status: R) -> Self {
///
/// # Examples
/// ```
/// use actix_web::{middleware::Logger, App, http::StatusCode};
///
/// // Log only the requests with status code higher or equal to BAD_REQUEST(400)
/// let app = App::new()
/// .wrap(Logger::default().statuses(StatusCode::BAD_REQUEST..));
///
/// ```
pub fn statuses<R: RangeBounds<StatusCode>>(mut self, status: R) -> Self {
let inner = Rc::get_mut(&mut self.0).unwrap();
inner.status_range = (status.start_bound().cloned(), status.end_bound().cloned());
self
Expand Down

0 comments on commit 2392c53

Please sign in to comment.