refactor(lib): Import tracing macros per-module

Instead of one #[macro_use] at the crate root.
This commit is contained in:
Jonas Platte
2021-08-29 14:31:20 +02:00
committed by Sean McArthur
parent 165ada34a3
commit a81c44f2c8
23 changed files with 35 additions and 16 deletions

View File

@@ -50,6 +50,8 @@ impl DecodedLength {
/// Checks the `u64` is within the maximum allowed for content-length. /// Checks the `u64` is within the maximum allowed for content-length.
#[cfg(any(feature = "http1", feature = "http2"))] #[cfg(any(feature = "http1", feature = "http2"))]
pub(crate) fn checked_new(len: u64) -> Result<Self, crate::error::Parse> { pub(crate) fn checked_new(len: u64) -> Result<Self, crate::error::Parse> {
use tracing::warn;
if len <= MAX_LEN { if len <= MAX_LEN {
Ok(DecodedLength(len)) Ok(DecodedLength(len))
} else { } else {

View File

@@ -8,6 +8,7 @@ use futures_util::future::{self, Either, FutureExt as _, TryFutureExt as _};
use http::header::{HeaderValue, HOST}; use http::header::{HeaderValue, HOST};
use http::uri::{Port, Scheme}; use http::uri::{Port, Scheme};
use http::{Method, Request, Response, Uri, Version}; use http::{Method, Request, Response, Uri, Version};
use tracing::{debug, trace, warn};
use super::conn; use super::conn;
use super::connect::{self, sealed::Connect, Alpn, Connected, Connection}; use super::connect::{self, sealed::Connect, Alpn, Connected, Connection};

View File

@@ -60,6 +60,7 @@ use httparse::ParserConfig;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use tokio::io::{AsyncRead, AsyncWrite}; use tokio::io::{AsyncRead, AsyncWrite};
use tower_service::Service; use tower_service::Service;
use tracing::{debug, trace};
use super::dispatch; use super::dispatch;
use crate::body::HttpBody; use crate::body::HttpBody;

View File

@@ -31,6 +31,7 @@ use std::{fmt, io, vec};
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use tower_service::Service; use tower_service::Service;
use tracing::debug;
pub(super) use self::sealed::Resolve; pub(super) use self::sealed::Resolve;

View File

@@ -14,6 +14,7 @@ use http::uri::{Scheme, Uri};
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use tokio::net::{TcpSocket, TcpStream}; use tokio::net::{TcpSocket, TcpStream};
use tokio::time::Sleep; use tokio::time::Sleep;
use tracing::{debug, trace, warn};
use super::dns::{self, resolve, GaiResolver, Resolve}; use super::dns::{self, resolve, GaiResolver, Resolve};
use super::{Connected, Connection}; use super::{Connected, Connection};

View File

@@ -235,6 +235,7 @@ impl<T, U> Callback<T, U> {
mut when: impl Future<Output = Result<U, (crate::Error, Option<T>)>> + Unpin, mut when: impl Future<Output = Result<U, (crate::Error, Option<T>)>> + Unpin,
) { ) {
use futures_util::future; use futures_util::future;
use tracing::trace;
let mut cb = Some(self); let mut cb = Some(self);

View File

@@ -10,6 +10,7 @@ use std::time::{Duration, Instant};
use futures_channel::oneshot; use futures_channel::oneshot;
#[cfg(feature = "runtime")] #[cfg(feature = "runtime")]
use tokio::time::{Duration, Instant, Interval}; use tokio::time::{Duration, Instant, Interval};
use tracing::{debug, trace};
use super::client::Ver; use super::client::Ver;
use crate::common::{exec::Exec, task, Future, Pin, Poll, Unpin}; use crate::common::{exec::Exec, task, Future, Pin, Poll, Unpin};

View File

@@ -6,6 +6,8 @@ use std::error::Error as StdError;
use std::future::Future; use std::future::Future;
use std::marker::PhantomData; use std::marker::PhantomData;
use tracing::debug;
use super::conn::{Builder, SendRequest}; use super::conn::{Builder, SendRequest};
use crate::{ use crate::{
body::HttpBody, body::HttpBody,

View File

@@ -58,13 +58,6 @@
#[doc(hidden)] #[doc(hidden)]
pub use http; pub use http;
#[cfg(any(
feature = "http1",
feature = "http2",
all(feature = "client", feature = "tcp")
))]
#[macro_use]
extern crate tracing;
#[cfg(all(test, feature = "nightly"))] #[cfg(all(test, feature = "nightly"))]
extern crate test; extern crate test;

View File

@@ -7,6 +7,7 @@ use http::header::{HeaderValue, CONNECTION};
use http::{HeaderMap, Method, Version}; use http::{HeaderMap, Method, Version};
use httparse::ParserConfig; use httparse::ParserConfig;
use tokio::io::{AsyncRead, AsyncWrite}; use tokio::io::{AsyncRead, AsyncWrite};
use tracing::{debug, error, trace};
use super::io::Buffered; use super::io::Buffered;
use super::{Decoder, Encode, EncodedBuf, Encoder, Http1Transaction, ParseContext, Wants}; use super::{Decoder, Encode, EncodedBuf, Encoder, Http1Transaction, ParseContext, Wants};
@@ -538,9 +539,8 @@ where
#[cfg(feature = "ffi")] #[cfg(feature = "ffi")]
{ {
self.state.on_informational = head self.state.on_informational =
.extensions head.extensions.remove::<crate::ffi::OnInformational>();
.remove::<crate::ffi::OnInformational>();
} }
Some(encoder) Some(encoder)

View File

@@ -4,6 +4,7 @@ use std::io;
use std::usize; use std::usize;
use bytes::Bytes; use bytes::Bytes;
use tracing::{debug, trace};
use crate::common::{task, Poll}; use crate::common::{task, Poll};

View File

@@ -3,6 +3,7 @@ use std::error::Error as StdError;
use bytes::{Buf, Bytes}; use bytes::{Buf, Bytes};
use http::Request; use http::Request;
use tokio::io::{AsyncRead, AsyncWrite}; use tokio::io::{AsyncRead, AsyncWrite};
use tracing::{debug, trace};
use super::{Http1Transaction, Wants}; use super::{Http1Transaction, Wants};
use crate::body::{Body, DecodedLength, HttpBody}; use crate::body::{Body, DecodedLength, HttpBody};

View File

@@ -3,6 +3,7 @@ use std::io::IoSlice;
use bytes::buf::{Chain, Take}; use bytes::buf::{Chain, Take};
use bytes::Buf; use bytes::Buf;
use tracing::trace;
use super::io::WriteBuf; use super::io::WriteBuf;

View File

@@ -6,6 +6,7 @@ use std::mem::MaybeUninit;
use bytes::{Buf, BufMut, Bytes, BytesMut}; use bytes::{Buf, BufMut, Bytes, BytesMut};
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
use tracing::{debug, trace};
use super::{Http1Transaction, ParseContext, ParsedMessage}; use super::{Http1Transaction, ParseContext, ParsedMessage};
use crate::common::buf::BufList; use crate::common::buf::BufList;

View File

@@ -8,6 +8,7 @@ use bytes::BytesMut;
use http::header::ValueIter; use http::header::ValueIter;
use http::header::{self, Entry, HeaderName, HeaderValue}; use http::header::{self, Entry, HeaderName, HeaderValue};
use http::{HeaderMap, Method, StatusCode, Version}; use http::{HeaderMap, Method, StatusCode, Version};
use tracing::{debug, error, trace, trace_span, warn};
use crate::body::DecodedLength; use crate::body::DecodedLength;
#[cfg(feature = "server")] #[cfg(feature = "server")]
@@ -117,9 +118,8 @@ impl Http1Transaction for Server {
}; };
{ {
/* SAFETY: it is safe to go from MaybeUninit array to array of MaybeUninit */ /* SAFETY: it is safe to go from MaybeUninit array to array of MaybeUninit */
let mut headers: [MaybeUninit<httparse::Header<'_>>; MAX_HEADERS] = unsafe { let mut headers: [MaybeUninit<httparse::Header<'_>>; MAX_HEADERS] =
MaybeUninit::uninit().assume_init() unsafe { MaybeUninit::uninit().assume_init() };
};
trace!( trace!(
"Request.parse([Header; {}], [u8; {}])", "Request.parse([Header; {}], [u8; {}])",
headers.len(), headers.len(),
@@ -886,9 +886,11 @@ impl Http1Transaction for Client {
); );
let mut res = httparse::Response::new(&mut []); let mut res = httparse::Response::new(&mut []);
let bytes = buf.as_ref(); let bytes = buf.as_ref();
match ctx.h1_parser_config match ctx.h1_parser_config.parse_response_with_uninit_headers(
.parse_response_with_uninit_headers(&mut res, bytes, &mut headers) &mut res,
{ bytes,
&mut headers,
) {
Ok(httparse::Status::Complete(len)) => { Ok(httparse::Status::Complete(len)) => {
trace!("Response.parse Complete({})", len); trace!("Response.parse Complete({})", len);
let status = StatusCode::from_u16(res.code.unwrap())?; let status = StatusCode::from_u16(res.code.unwrap())?;

View File

@@ -9,6 +9,7 @@ use futures_util::stream::StreamExt as _;
use h2::client::{Builder, SendRequest}; use h2::client::{Builder, SendRequest};
use http::{Method, StatusCode}; use http::{Method, StatusCode};
use tokio::io::{AsyncRead, AsyncWrite}; use tokio::io::{AsyncRead, AsyncWrite};
use tracing::{debug, trace, warn};
use super::{ping, H2Upgraded, PipeToSendStream, SendBuf}; use super::{ping, H2Upgraded, PipeToSendStream, SendBuf};
use crate::body::HttpBody; use crate::body::HttpBody;

View File

@@ -8,6 +8,7 @@ use std::io::{self, Cursor, IoSlice};
use std::mem; use std::mem;
use std::task::Context; use std::task::Context;
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
use tracing::{debug, trace, warn};
use crate::body::HttpBody; use crate::body::HttpBody;
use crate::common::{task, Future, Pin, Poll}; use crate::common::{task, Future, Pin, Poll};

View File

@@ -34,6 +34,7 @@ use std::time::Instant;
use h2::{Ping, PingPong}; use h2::{Ping, PingPong};
#[cfg(feature = "runtime")] #[cfg(feature = "runtime")]
use tokio::time::{Instant, Sleep}; use tokio::time::{Instant, Sleep};
use tracing::{debug, trace};
type WindowSize = u32; type WindowSize = u32;

View File

@@ -9,6 +9,7 @@ use h2::{Reason, RecvStream};
use http::{Method, Request}; use http::{Method, Request};
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use tokio::io::{AsyncRead, AsyncWrite}; use tokio::io::{AsyncRead, AsyncWrite};
use tracing::{debug, trace, warn};
use super::{ping, PipeToSendStream, SendBuf}; use super::{ping, PipeToSendStream, SendBuf};
use crate::body::HttpBody; use crate::body::HttpBody;

View File

@@ -55,6 +55,7 @@ use std::time::Duration;
use bytes::Bytes; use bytes::Bytes;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use tokio::io::{AsyncRead, AsyncWrite}; use tokio::io::{AsyncRead, AsyncWrite};
use tracing::trace;
use super::accept::Accept; use super::accept::Accept;
use crate::body::{Body, HttpBody}; use crate::body::{Body, HttpBody};
@@ -1037,6 +1038,7 @@ where
pub(crate) mod spawn_all { pub(crate) mod spawn_all {
use std::error::Error as StdError; use std::error::Error as StdError;
use tokio::io::{AsyncRead, AsyncWrite}; use tokio::io::{AsyncRead, AsyncWrite};
use tracing::debug;
use super::{Connecting, UpgradeableConnection}; use super::{Connecting, UpgradeableConnection};
use crate::body::{Body, HttpBody}; use crate::body::{Body, HttpBody};

View File

@@ -2,6 +2,7 @@ use std::error::Error as StdError;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use tokio::io::{AsyncRead, AsyncWrite}; use tokio::io::{AsyncRead, AsyncWrite};
use tracing::debug;
use super::accept::Accept; use super::accept::Accept;
use super::conn::{SpawnAll, UpgradeableConnection, Watcher}; use super::conn::{SpawnAll, UpgradeableConnection, Watcher};

View File

@@ -5,6 +5,7 @@ use std::time::Duration;
use tokio::net::TcpListener; use tokio::net::TcpListener;
use tokio::time::Sleep; use tokio::time::Sleep;
use tracing::{debug, error, trace};
use crate::common::{task, Future, Pin, Poll}; use crate::common::{task, Future, Pin, Poll};

View File

@@ -14,6 +14,8 @@ use std::marker::Unpin;
use bytes::Bytes; use bytes::Bytes;
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
use tokio::sync::oneshot; use tokio::sync::oneshot;
#[cfg(any(feature = "http1", feature = "http2"))]
use tracing::trace;
use crate::common::io::Rewind; use crate::common::io::Rewind;
use crate::common::{task, Future, Pin, Poll}; use crate::common::{task, Future, Pin, Poll};