feat(log): clean up logging
This commit is contained in:
@@ -182,7 +182,7 @@ impl<'a, U: IntoUrl> RequestBuilder<'a, U> {
|
||||
pub fn send(self) -> HttpResult<Response> {
|
||||
let RequestBuilder { client, method, url, headers, body } = self;
|
||||
let mut url = try!(url.into_url());
|
||||
debug!("client.request {:?} {:?}", method, url);
|
||||
trace!("send {:?} {:?}", method, url);
|
||||
|
||||
let can_have_body = match &method {
|
||||
&Method::Get | &Method::Head => false,
|
||||
@@ -364,12 +364,12 @@ fn get_host_and_port(url: &Url) -> HttpResult<(String, u16)> {
|
||||
Some(host) => host,
|
||||
None => return Err(HttpUriError(UrlError::EmptyHost))
|
||||
};
|
||||
debug!("host={:?}", host);
|
||||
trace!("host={:?}", host);
|
||||
let port = match url.port_or_default() {
|
||||
Some(port) => port,
|
||||
None => return Err(HttpUriError(UrlError::InvalidPort))
|
||||
};
|
||||
debug!("port={:?}", port);
|
||||
trace!("port={:?}", port);
|
||||
Ok((host, port))
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,6 @@ impl Request<Fresh> {
|
||||
-> HttpResult<Request<Fresh>> where
|
||||
C: NetworkConnector<Stream=S>,
|
||||
S: Into<Box<NetworkStream + Send>> {
|
||||
debug!("{} {}", method, url);
|
||||
let (host, port) = try!(get_host_and_port(&url));
|
||||
|
||||
let stream = try!(connector.connect(&*host, port, &*url.scheme)).into();
|
||||
@@ -84,14 +83,14 @@ impl Request<Fresh> {
|
||||
uri.push_str(&q[..]);
|
||||
}
|
||||
|
||||
debug!("writing head: {:?} {:?} {:?}", self.method, uri, self.version);
|
||||
debug!("request line: {:?} {:?} {:?}", self.method, uri, self.version);
|
||||
try!(write!(&mut self.body, "{} {} {}{}",
|
||||
self.method, uri, self.version, LINE_ENDING));
|
||||
|
||||
|
||||
let stream = match self.method {
|
||||
Method::Get | Method::Head => {
|
||||
debug!("headers [\n{:?}]", self.headers);
|
||||
debug!("headers={:?}", self.headers);
|
||||
try!(write!(&mut self.body, "{}{}", self.headers, LINE_ENDING));
|
||||
EmptyWriter(self.body.into_inner())
|
||||
},
|
||||
@@ -124,7 +123,7 @@ impl Request<Fresh> {
|
||||
}
|
||||
}
|
||||
|
||||
debug!("headers [\n{:?}]", self.headers);
|
||||
debug!("headers={:?}", self.headers);
|
||||
try!(write!(&mut self.body, "{}{}", self.headers, LINE_ENDING));
|
||||
|
||||
if chunked {
|
||||
|
||||
@@ -46,13 +46,13 @@ impl Response {
|
||||
match headers.get::<TransferEncoding>() {
|
||||
Some(&TransferEncoding(ref codings)) => {
|
||||
if codings.len() > 1 {
|
||||
debug!("TODO: #2 handle other codings: {:?}", codings);
|
||||
trace!("TODO: #2 handle other codings: {:?}", codings);
|
||||
};
|
||||
|
||||
if codings.contains(&Chunked) {
|
||||
ChunkedReader(stream, None)
|
||||
} else {
|
||||
debug!("not chuncked. read till eof");
|
||||
trace!("not chuncked. read till eof");
|
||||
EofReader(stream)
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ impl Response {
|
||||
None => unreachable!()
|
||||
}
|
||||
} else {
|
||||
debug!("neither Transfer-Encoding nor Content-Length");
|
||||
trace!("neither Transfer-Encoding nor Content-Length");
|
||||
EofReader(stream)
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user