mirror of
https://github.com/actix/actix-web.git
synced 2024-11-26 03:21:08 +00:00
Fix logger request duration calculation
This commit is contained in:
parent
9d39f441e9
commit
83bf852192
3 changed files with 11 additions and 13 deletions
|
@ -19,6 +19,8 @@
|
|||
|
||||
* Fix client connection pooling
|
||||
|
||||
* Fix logger request duration calculation #152
|
||||
|
||||
|
||||
## 0.4.10 (2018-03-20)
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@ fn index(_req: HttpRequest) -> &'static str {
|
|||
|
||||
fn main() {
|
||||
::std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
let _ = env_logger::init();
|
||||
let sys = actix::System::new("ws-example");
|
||||
env_logger::init();
|
||||
let sys = actix::System::new("hello-world");
|
||||
|
||||
let _addr = server::new(
|
||||
server::new(
|
||||
|| App::new()
|
||||
// enable logger
|
||||
.middleware(middleware::Logger::default())
|
||||
|
|
|
@ -231,18 +231,14 @@ impl FormatText {
|
|||
FormatText::ResponseSize => resp.response_size().fmt(fmt),
|
||||
FormatText::Pid => unsafe{libc::getpid().fmt(fmt)},
|
||||
FormatText::Time => {
|
||||
let response_time = time::now() - entry_time;
|
||||
let response_time = response_time.num_seconds() as f64 +
|
||||
(response_time.num_nanoseconds().unwrap_or(0) as f64)/1_000_000_000.0;
|
||||
|
||||
fmt.write_fmt(format_args!("{:.6}", response_time))
|
||||
let rt = time::now() - entry_time;
|
||||
let rt = (rt.num_nanoseconds().unwrap_or(0) as f64) / 1_000_000_000.0;
|
||||
fmt.write_fmt(format_args!("{:.6}", rt))
|
||||
},
|
||||
FormatText::TimeMillis => {
|
||||
let response_time = time::now() - entry_time;
|
||||
let response_time_ms = (response_time.num_seconds() * 1000) as f64 +
|
||||
(response_time.num_nanoseconds().unwrap_or(0) as f64)/1_000_000.0;
|
||||
|
||||
fmt.write_fmt(format_args!("{:.6}", response_time_ms))
|
||||
let rt = time::now() - entry_time;
|
||||
let rt = (rt.num_nanoseconds().unwrap_or(0) as f64) / 1_000_000.0;
|
||||
fmt.write_fmt(format_args!("{:.6}", rt))
|
||||
},
|
||||
FormatText::RemoteAddr => {
|
||||
if let Some(remote) = req.connection_info().remote() {
|
||||
|
|
Loading…
Reference in a new issue