Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logger doesn't log errors #58

Open
adamreeve opened this issue May 11, 2015 · 0 comments
Open

Logger doesn't log errors #58

adamreeve opened this issue May 11, 2015 · 0 comments

Comments

@adamreeve
Copy link
Contributor

I don't know whether this is a bug in iron/logger or iron/router, but when the router has a 404 or 301 response, it returns an Err, and logger doesn't log anything. Either router should return an Ok with the 401 or 301 status, or logger should handle logging when there's an error. I'm thinking it's the latter.

Example app demonstrating this problem:

extern crate iron;
extern crate logger;
extern crate router;

use iron::prelude::*;
use iron::status;

use logger::Logger;
use router::Router;

fn handle_hello(_ : &mut Request) -> IronResult<Response> {
    Ok(Response::with((status::Ok, "Hello world")))
}

fn main() {
    let (logger_before, logger_after) = Logger::new(None);

    let mut router = Router::new();

    router.get("/hello", handle_hello);

    let mut chain = Chain::new(router);

    chain.link_before(logger_before);
    chain.link_after(logger_after);

    Iron::new(chain).http("0.0.0.0:8080").unwrap();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant