iron / logger

Morgan-inspired request logger middleware for Iron
MIT License
25 stars 37 forks source link

500 Server Error ! logger = "0.1.0" #87

Closed TakWolf closed 11 months ago

TakWolf commented 8 years ago
[dependencies]
iron = "0.4.0"
router = "0.2.0"
logger = "0.1.0"
extern crate iron;
extern crate router;
extern crate logger;

use iron::prelude::*;
use iron::status;
use router::Router;
use logger::Logger;

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

fn main() {

    let mut router = Router::new();
    router.get("/", handler);
    router.get("/:query", handler);

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

    let (logger_before, logger_after) = Logger::new(None);
    chain.link_before(logger_before);
    chain.link_after(logger_after);

    Iron::new(chain).http("localhost:3000").unwrap();

}

I got a 500 server error if I link logger to chain.

Hoverbear commented 8 years ago

I'm not seeing this issue:

 hoverbear > cargo run
     Running `target/debug/iron-test`
GET http://localhost:3000/ -> 200 OK (0.103265 ms)
GET http://localhost:3000/foo -> 200 OK (0.151203 ms)

What is giving you the error exactly? Where do you visit?

TakWolf commented 8 years ago

@Hoverbear All of the code above , I visit on Chrome with F12, I see a 500 error, but response nothing. And there is nothing in the server console.

I don't know why. It seems that problem lies in logger , because if I don't link logger :

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

I will run correctly and response the message.

TakWolf commented 8 years ago

I have try again and this error is only on Windows. On macOS, it work well.

image

Is this my problem?

Hoverbear commented 8 years ago

Perhaps it is! I've never used Windows for programming. I wonder if any of our other maintainers use Windows...

std is pretty good with compatibility. I wonder if it's related to us using term? Check out https://github.com/Stebalien/term and look at https://github.com/Stebalien/term#packaging-and-distributing ? Does that maybe help somehow?

TakWolf commented 8 years ago

Thanks, I will depth learn about this!

Hoverbear commented 8 years ago

@TakWolf Happy to help any way I can, but it's not much. :) Some folks on IRC might have some advice. At the very least I think you can get someone to confirm the issue!

Boscop commented 7 years ago

Why does this logger work on windows with Iron, but not iron/logger?