mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
* Log error results in Logger middleware (closes #938) * Log internal server errors with an ERROR log level * Logger middleware: don't log 500 internal server errors, as Actix now logs them always * Changelog
This commit is contained in:
parent
b36fdc46db
commit
d03296237e
11
CHANGES.md
11
CHANGES.md
@ -1,5 +1,16 @@
|
||||
# Changes
|
||||
|
||||
## [1.0.5] - ?
|
||||
|
||||
### Added
|
||||
|
||||
* Actix now logs errors resulting in "internal server error" responses always, with the `error`
|
||||
logging level
|
||||
|
||||
### Fixed
|
||||
|
||||
* Restored logging of errors through the `Logger` middleware
|
||||
|
||||
## [1.0.4] - 2019-07-17
|
||||
|
||||
### Added
|
||||
|
@ -52,6 +52,9 @@ impl Response<Body> {
|
||||
#[inline]
|
||||
pub fn from_error(error: Error) -> Response {
|
||||
let mut resp = error.as_response_error().render_response();
|
||||
if resp.head.status == StatusCode::INTERNAL_SERVER_ERROR {
|
||||
error!("Internal Server Error: {:?}", error);
|
||||
}
|
||||
resp.error = Some(error);
|
||||
resp
|
||||
}
|
||||
|
@ -9,12 +9,13 @@ use actix_service::{Service, Transform};
|
||||
use bytes::Bytes;
|
||||
use futures::future::{ok, FutureResult};
|
||||
use futures::{Async, Future, Poll};
|
||||
use log::debug;
|
||||
use regex::Regex;
|
||||
use time;
|
||||
|
||||
use crate::dev::{BodySize, MessageBody, ResponseBody};
|
||||
use crate::error::{Error, Result};
|
||||
use crate::http::{HeaderName, HttpTryFrom};
|
||||
use crate::http::{HeaderName, HttpTryFrom, StatusCode};
|
||||
use crate::service::{ServiceRequest, ServiceResponse};
|
||||
use crate::HttpResponse;
|
||||
|
||||
@ -202,6 +203,12 @@ where
|
||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||
let res = futures::try_ready!(self.fut.poll());
|
||||
|
||||
if let Some(error) = res.response().error() {
|
||||
if res.response().head().status != StatusCode::INTERNAL_SERVER_ERROR {
|
||||
debug!("Error in response: {:?}", error);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ref mut format) = self.format {
|
||||
for unit in &mut format.0 {
|
||||
unit.render_response(res.response());
|
||||
|
Loading…
Reference in New Issue
Block a user