add request name in custom log enum variant

This commit is contained in:
jdeepee 2020-10-28 10:55:27 +00:00
parent c46b2609d9
commit 0577211acb
1 changed files with 4 additions and 4 deletions

View File

@ -134,12 +134,12 @@ impl Logger {
let inner = Rc::get_mut(&mut self.0).unwrap();
let pos = inner.format.0.iter().position(|tf| match tf {
FormatText::CustomLog(inner_label, _) => label == inner_label,
FormatText::CustomRequestLog(inner_label, _) => label == inner_label,
_ => false,
});
match pos {
Some(pos) => match &mut inner.format.0[pos] {
FormatText::CustomLog(_, inner_closure) => {
FormatText::CustomRequestLog(_, inner_closure) => {
*inner_closure = Some(CustomRequestFn {
inner_fn: Rc::new(closure),
})
@ -383,7 +383,7 @@ impl Format {
HeaderName::try_from(key.as_str()).unwrap(),
),
"e" => FormatText::EnvironHeader(key.as_str().to_owned()),
"xi" => FormatText::CustomLog(key.as_str().to_owned(), None),
"xi" => FormatText::CustomRequestLog(key.as_str().to_owned(), None),
_ => unreachable!(),
})
} else {
@ -429,7 +429,7 @@ pub enum FormatText {
RequestHeader(HeaderName),
ResponseHeader(HeaderName),
EnvironHeader(String),
CustomLog(String, Option<CustomRequestFn>),
CustomRequestLog(String, Option<CustomRequestFn>),
}
#[derive(Clone)]