Struct logger::Logger
[−]
[src]
pub struct Logger { /* fields omitted */ }
Middleware
for logging request and response info to the terminal.
Methods
impl Logger
[src]
fn new(format: Option<Format>) -> (Logger, Logger)
[src]
Create a pair of Logger
middlewares with the specified format
. If a None
is passed in, uses the default format:
⚠Be careful when using this code, it's not being tested!
{method} {uri} -> {status} ({response-time} ms)
While the returned value can be passed straight to Chain::link
, consider making the logger BeforeMiddleware
the first in your chain and the logger AfterMiddleware
the last by doing something like this:
⚠Be careful when using this code, it's not being tested!
let mut chain = Chain::new(handler); let (logger_before, logger_after) = Logger::new(None); chain.link_before(logger_before); // link other middlewares here... chain.link_after(logger_after);
Trait Implementations
impl BeforeMiddleware for Logger
[src]
fn before(&self, req: &mut Request) -> IronResult<()>
[src]
Do whatever work this middleware should do with a Request
object.
fn catch(&self, req: &mut Request, err: IronError) -> IronResult<()>
[src]
Respond to an error thrown by a previous BeforeMiddleware
. Read more
impl AfterMiddleware for Logger
[src]
fn after(&self, req: &mut Request, res: Response) -> IronResult<Response>
[src]
Do whatever post-processing this middleware should do.
fn catch(&self, req: &mut Request, err: IronError) -> IronResult<Response>
[src]
Respond to an error thrown by previous AfterMiddleware
, the Handler
, or a BeforeMiddleware
. Read more