diff --git a/actix-web/src/middleware/logger.rs b/actix-web/src/middleware/logger.rs index dc1b02399..bbfbb9092 100644 --- a/actix-web/src/middleware/logger.rs +++ b/actix-web/src/middleware/logger.rs @@ -10,6 +10,7 @@ use std::{ pin::Pin, rc::Rc, task::{Context, Poll}, + thread::current }; use actix_service::{Service, Transform}; @@ -512,6 +513,7 @@ impl Format { "U" => FormatText::UrlPath, "T" => FormatText::Time, "D" => FormatText::TimeMillis, + "P" => FormatText::ThreadName, _ => FormatText::Str(m.as_str().to_owned()), }); } @@ -531,6 +533,7 @@ impl Format { #[derive(Debug, Clone)] enum FormatText { Str(String), + ThreadName, Percent, RequestLine, RequestTime, @@ -610,6 +613,9 @@ impl FormatText { "-".fmt(fmt) } } + FormatText::ThreadName() => { + fmt.write_fmt(format_args!("{}", current().name().unwrap())) + } _ => Ok(()), } }