mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-24 07:53:00 +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
|
# 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
|
## [1.0.4] - 2019-07-17
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -52,6 +52,9 @@ impl Response<Body> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_error(error: Error) -> Response {
|
pub fn from_error(error: Error) -> Response {
|
||||||
let mut resp = error.as_response_error().render_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.error = Some(error);
|
||||||
resp
|
resp
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,13 @@ use actix_service::{Service, Transform};
|
|||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::future::{ok, FutureResult};
|
use futures::future::{ok, FutureResult};
|
||||||
use futures::{Async, Future, Poll};
|
use futures::{Async, Future, Poll};
|
||||||
|
use log::debug;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use time;
|
use time;
|
||||||
|
|
||||||
use crate::dev::{BodySize, MessageBody, ResponseBody};
|
use crate::dev::{BodySize, MessageBody, ResponseBody};
|
||||||
use crate::error::{Error, Result};
|
use crate::error::{Error, Result};
|
||||||
use crate::http::{HeaderName, HttpTryFrom};
|
use crate::http::{HeaderName, HttpTryFrom, StatusCode};
|
||||||
use crate::service::{ServiceRequest, ServiceResponse};
|
use crate::service::{ServiceRequest, ServiceResponse};
|
||||||
use crate::HttpResponse;
|
use crate::HttpResponse;
|
||||||
|
|
||||||
@ -202,6 +203,12 @@ where
|
|||||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||||
let res = futures::try_ready!(self.fut.poll());
|
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 {
|
if let Some(ref mut format) = self.format {
|
||||||
for unit in &mut format.0 {
|
for unit in &mut format.0 {
|
||||||
unit.render_response(res.response());
|
unit.render_response(res.response());
|
||||||
|
Loading…
Reference in New Issue
Block a user