Closed jaemk closed 6 years ago
I'm not familiar enough with the log
crate. Will we need to bump the major version of rouille if the log crate gets bumped to 0.4 in the future?
Ah, that's a good point. The "loggers" implement traits from the log
crate, so yeah it seems you would need to keep the log
crate up to date to work with the latest "loggers". That's unfortunate. Maybe the alternate logging function could instead return a tuple containing the formatted log message? Then it can be passed onto whatever logger is being used.
// still not sure about the name
fn request_info<F: FnOnce()> -> Response>(rq: &Request, f: F) -> (String, Response);
Scratch that. Returning a message wouldn't work when the handler panics
A better solution would probably be to accept logging functions:
fn log_custom<F, L, E>(rq: &Request, log_ok_f: L, log_err_f: E, handler: F) -> Response
where F: FnOnce() -> Response,
L: Fn(&Request, &Response, std::time::Duration),
E: Fn(&Request, std::time::Duration)
Alright, I've updated to the log_custom
signature above. Also updated rouille::log
docs and bumped chrono
to 0.4.0 (only used internally by rouille::log
).
It'd be nice to have the option to incorporate request logging with an app's
env_logger
or whatever logging backend is being used.The name is up for debate, not sure what else to call an alternate logging function.