fix proxy response bug, add log for response object
This commit is contained in:
parent
1a80e405b5
commit
8a4149cbf2
4 changed files with 50 additions and 7 deletions
33
src/msg_handler/utils_response.rs
Normal file
33
src/msg_handler/utils_response.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
use crate::{log::*, utils::*};
|
||||
use hyper::Response;
|
||||
use std::fmt::Display;
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// Functions of utils for request messages
|
||||
pub trait ResLog {
|
||||
fn log<T1: Display, T2: Display + ToCanonical>(
|
||||
self,
|
||||
server_name: &T1,
|
||||
client_addr: &T2,
|
||||
extra: Option<&str>,
|
||||
);
|
||||
}
|
||||
impl<B> ResLog for &Response<B> {
|
||||
fn log<T1: Display, T2: Display + ToCanonical>(
|
||||
self,
|
||||
server_name: &T1,
|
||||
client_addr: &T2,
|
||||
extra: Option<&str>,
|
||||
) {
|
||||
let canonical_client_addr = client_addr.to_canonical();
|
||||
info!(
|
||||
"{} <- {} -- {} {:?} {:?} {}",
|
||||
canonical_client_addr,
|
||||
server_name,
|
||||
self.status(),
|
||||
self.version(),
|
||||
self.headers(),
|
||||
extra.map_or_else(|| "", |v| v)
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue