From 2392c53af90d8af9b1642c62bcd77ae4df40933b Mon Sep 17 00:00:00 2001 From: Tglman Date: Wed, 26 Jul 2023 00:14:11 +0100 Subject: [PATCH] update new method for status filter in log middleware, add documentation --- actix-web/src/middleware/logger.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/actix-web/src/middleware/logger.rs b/actix-web/src/middleware/logger.rs index 8206b47ba77..bf0abd08df9 100644 --- a/actix-web/src/middleware/logger.rs +++ b/actix-web/src/middleware/logger.rs @@ -128,7 +128,17 @@ impl Logger { } /// Set a range of status to include in the logging - pub fn status_range>(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>(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