refactor(lib): Import tracing macros per-module
Instead of one #[macro_use] at the crate root.
This commit is contained in:
		
				
					committed by
					
						 Sean McArthur
						Sean McArthur
					
				
			
			
				
	
			
			
			
						parent
						
							165ada34a3
						
					
				
				
					commit
					a81c44f2c8
				
			| @@ -50,6 +50,8 @@ impl DecodedLength { | ||||
|     /// Checks the `u64` is within the maximum allowed for content-length. | ||||
|     #[cfg(any(feature = "http1", feature = "http2"))] | ||||
|     pub(crate) fn checked_new(len: u64) -> Result<Self, crate::error::Parse> { | ||||
|         use tracing::warn; | ||||
|  | ||||
|         if len <= MAX_LEN { | ||||
|             Ok(DecodedLength(len)) | ||||
|         } else { | ||||
|   | ||||
| @@ -8,6 +8,7 @@ use futures_util::future::{self, Either, FutureExt as _, TryFutureExt as _}; | ||||
| use http::header::{HeaderValue, HOST}; | ||||
| use http::uri::{Port, Scheme}; | ||||
| use http::{Method, Request, Response, Uri, Version}; | ||||
| use tracing::{debug, trace, warn}; | ||||
|  | ||||
| use super::conn; | ||||
| use super::connect::{self, sealed::Connect, Alpn, Connected, Connection}; | ||||
|   | ||||
| @@ -60,6 +60,7 @@ use httparse::ParserConfig; | ||||
| use pin_project_lite::pin_project; | ||||
| use tokio::io::{AsyncRead, AsyncWrite}; | ||||
| use tower_service::Service; | ||||
| use tracing::{debug, trace}; | ||||
|  | ||||
| use super::dispatch; | ||||
| use crate::body::HttpBody; | ||||
|   | ||||
| @@ -31,6 +31,7 @@ use std::{fmt, io, vec}; | ||||
|  | ||||
| use tokio::task::JoinHandle; | ||||
| use tower_service::Service; | ||||
| use tracing::debug; | ||||
|  | ||||
| pub(super) use self::sealed::Resolve; | ||||
|  | ||||
|   | ||||
| @@ -14,6 +14,7 @@ use http::uri::{Scheme, Uri}; | ||||
| use pin_project_lite::pin_project; | ||||
| use tokio::net::{TcpSocket, TcpStream}; | ||||
| use tokio::time::Sleep; | ||||
| use tracing::{debug, trace, warn}; | ||||
|  | ||||
| use super::dns::{self, resolve, GaiResolver, Resolve}; | ||||
| use super::{Connected, Connection}; | ||||
|   | ||||
| @@ -235,6 +235,7 @@ impl<T, U> Callback<T, U> { | ||||
|         mut when: impl Future<Output = Result<U, (crate::Error, Option<T>)>> + Unpin, | ||||
|     ) { | ||||
|         use futures_util::future; | ||||
|         use tracing::trace; | ||||
|  | ||||
|         let mut cb = Some(self); | ||||
|  | ||||
|   | ||||
| @@ -10,6 +10,7 @@ use std::time::{Duration, Instant}; | ||||
| use futures_channel::oneshot; | ||||
| #[cfg(feature = "runtime")] | ||||
| use tokio::time::{Duration, Instant, Interval}; | ||||
| use tracing::{debug, trace}; | ||||
|  | ||||
| use super::client::Ver; | ||||
| use crate::common::{exec::Exec, task, Future, Pin, Poll, Unpin}; | ||||
|   | ||||
| @@ -6,6 +6,8 @@ use std::error::Error as StdError; | ||||
| use std::future::Future; | ||||
| use std::marker::PhantomData; | ||||
|  | ||||
| use tracing::debug; | ||||
|  | ||||
| use super::conn::{Builder, SendRequest}; | ||||
| use crate::{ | ||||
|     body::HttpBody, | ||||
|   | ||||
| @@ -58,13 +58,6 @@ | ||||
|  | ||||
| #[doc(hidden)] | ||||
| pub use http; | ||||
| #[cfg(any( | ||||
|     feature = "http1", | ||||
|     feature = "http2", | ||||
|     all(feature = "client", feature = "tcp") | ||||
| ))] | ||||
| #[macro_use] | ||||
| extern crate tracing; | ||||
|  | ||||
| #[cfg(all(test, feature = "nightly"))] | ||||
| extern crate test; | ||||
|   | ||||
| @@ -7,6 +7,7 @@ use http::header::{HeaderValue, CONNECTION}; | ||||
| use http::{HeaderMap, Method, Version}; | ||||
| use httparse::ParserConfig; | ||||
| use tokio::io::{AsyncRead, AsyncWrite}; | ||||
| use tracing::{debug, error, trace}; | ||||
|  | ||||
| use super::io::Buffered; | ||||
| use super::{Decoder, Encode, EncodedBuf, Encoder, Http1Transaction, ParseContext, Wants}; | ||||
| @@ -538,9 +539,8 @@ where | ||||
|  | ||||
|                 #[cfg(feature = "ffi")] | ||||
|                 { | ||||
|                     self.state.on_informational = head | ||||
|                         .extensions | ||||
|                         .remove::<crate::ffi::OnInformational>(); | ||||
|                     self.state.on_informational = | ||||
|                         head.extensions.remove::<crate::ffi::OnInformational>(); | ||||
|                 } | ||||
|  | ||||
|                 Some(encoder) | ||||
|   | ||||
| @@ -4,6 +4,7 @@ use std::io; | ||||
| use std::usize; | ||||
|  | ||||
| use bytes::Bytes; | ||||
| use tracing::{debug, trace}; | ||||
|  | ||||
| use crate::common::{task, Poll}; | ||||
|  | ||||
|   | ||||
| @@ -3,6 +3,7 @@ use std::error::Error as StdError; | ||||
| use bytes::{Buf, Bytes}; | ||||
| use http::Request; | ||||
| use tokio::io::{AsyncRead, AsyncWrite}; | ||||
| use tracing::{debug, trace}; | ||||
|  | ||||
| use super::{Http1Transaction, Wants}; | ||||
| use crate::body::{Body, DecodedLength, HttpBody}; | ||||
|   | ||||
| @@ -3,6 +3,7 @@ use std::io::IoSlice; | ||||
|  | ||||
| use bytes::buf::{Chain, Take}; | ||||
| use bytes::Buf; | ||||
| use tracing::trace; | ||||
|  | ||||
| use super::io::WriteBuf; | ||||
|  | ||||
|   | ||||
| @@ -6,6 +6,7 @@ use std::mem::MaybeUninit; | ||||
|  | ||||
| use bytes::{Buf, BufMut, Bytes, BytesMut}; | ||||
| use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; | ||||
| use tracing::{debug, trace}; | ||||
|  | ||||
| use super::{Http1Transaction, ParseContext, ParsedMessage}; | ||||
| use crate::common::buf::BufList; | ||||
|   | ||||
| @@ -8,6 +8,7 @@ use bytes::BytesMut; | ||||
| use http::header::ValueIter; | ||||
| use http::header::{self, Entry, HeaderName, HeaderValue}; | ||||
| use http::{HeaderMap, Method, StatusCode, Version}; | ||||
| use tracing::{debug, error, trace, trace_span, warn}; | ||||
|  | ||||
| use crate::body::DecodedLength; | ||||
| #[cfg(feature = "server")] | ||||
| @@ -117,9 +118,8 @@ impl Http1Transaction for Server { | ||||
|         }; | ||||
|         { | ||||
|             /* SAFETY: it is safe to go from MaybeUninit array to array of MaybeUninit */ | ||||
|             let mut headers: [MaybeUninit<httparse::Header<'_>>; MAX_HEADERS] = unsafe { | ||||
|                 MaybeUninit::uninit().assume_init() | ||||
|             }; | ||||
|             let mut headers: [MaybeUninit<httparse::Header<'_>>; MAX_HEADERS] = | ||||
|                 unsafe { MaybeUninit::uninit().assume_init() }; | ||||
|             trace!( | ||||
|                 "Request.parse([Header; {}], [u8; {}])", | ||||
|                 headers.len(), | ||||
| @@ -886,9 +886,11 @@ impl Http1Transaction for Client { | ||||
|                 ); | ||||
|                 let mut res = httparse::Response::new(&mut []); | ||||
|                 let bytes = buf.as_ref(); | ||||
|                 match ctx.h1_parser_config | ||||
|                     .parse_response_with_uninit_headers(&mut res, bytes, &mut headers) | ||||
|                 { | ||||
|                 match ctx.h1_parser_config.parse_response_with_uninit_headers( | ||||
|                     &mut res, | ||||
|                     bytes, | ||||
|                     &mut headers, | ||||
|                 ) { | ||||
|                     Ok(httparse::Status::Complete(len)) => { | ||||
|                         trace!("Response.parse Complete({})", len); | ||||
|                         let status = StatusCode::from_u16(res.code.unwrap())?; | ||||
|   | ||||
| @@ -9,6 +9,7 @@ use futures_util::stream::StreamExt as _; | ||||
| use h2::client::{Builder, SendRequest}; | ||||
| use http::{Method, StatusCode}; | ||||
| use tokio::io::{AsyncRead, AsyncWrite}; | ||||
| use tracing::{debug, trace, warn}; | ||||
|  | ||||
| use super::{ping, H2Upgraded, PipeToSendStream, SendBuf}; | ||||
| use crate::body::HttpBody; | ||||
|   | ||||
| @@ -8,6 +8,7 @@ use std::io::{self, Cursor, IoSlice}; | ||||
| use std::mem; | ||||
| use std::task::Context; | ||||
| use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; | ||||
| use tracing::{debug, trace, warn}; | ||||
|  | ||||
| use crate::body::HttpBody; | ||||
| use crate::common::{task, Future, Pin, Poll}; | ||||
|   | ||||
| @@ -34,6 +34,7 @@ use std::time::Instant; | ||||
| use h2::{Ping, PingPong}; | ||||
| #[cfg(feature = "runtime")] | ||||
| use tokio::time::{Instant, Sleep}; | ||||
| use tracing::{debug, trace}; | ||||
|  | ||||
| type WindowSize = u32; | ||||
|  | ||||
|   | ||||
| @@ -9,6 +9,7 @@ use h2::{Reason, RecvStream}; | ||||
| use http::{Method, Request}; | ||||
| use pin_project_lite::pin_project; | ||||
| use tokio::io::{AsyncRead, AsyncWrite}; | ||||
| use tracing::{debug, trace, warn}; | ||||
|  | ||||
| use super::{ping, PipeToSendStream, SendBuf}; | ||||
| use crate::body::HttpBody; | ||||
|   | ||||
| @@ -55,6 +55,7 @@ use std::time::Duration; | ||||
| use bytes::Bytes; | ||||
| use pin_project_lite::pin_project; | ||||
| use tokio::io::{AsyncRead, AsyncWrite}; | ||||
| use tracing::trace; | ||||
|  | ||||
| use super::accept::Accept; | ||||
| use crate::body::{Body, HttpBody}; | ||||
| @@ -1037,6 +1038,7 @@ where | ||||
| pub(crate) mod spawn_all { | ||||
|     use std::error::Error as StdError; | ||||
|     use tokio::io::{AsyncRead, AsyncWrite}; | ||||
|     use tracing::debug; | ||||
|  | ||||
|     use super::{Connecting, UpgradeableConnection}; | ||||
|     use crate::body::{Body, HttpBody}; | ||||
|   | ||||
| @@ -2,6 +2,7 @@ use std::error::Error as StdError; | ||||
|  | ||||
| use pin_project_lite::pin_project; | ||||
| use tokio::io::{AsyncRead, AsyncWrite}; | ||||
| use tracing::debug; | ||||
|  | ||||
| use super::accept::Accept; | ||||
| use super::conn::{SpawnAll, UpgradeableConnection, Watcher}; | ||||
|   | ||||
| @@ -5,6 +5,7 @@ use std::time::Duration; | ||||
|  | ||||
| use tokio::net::TcpListener; | ||||
| use tokio::time::Sleep; | ||||
| use tracing::{debug, error, trace}; | ||||
|  | ||||
| use crate::common::{task, Future, Pin, Poll}; | ||||
|  | ||||
|   | ||||
| @@ -14,6 +14,8 @@ use std::marker::Unpin; | ||||
| use bytes::Bytes; | ||||
| use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; | ||||
| use tokio::sync::oneshot; | ||||
| #[cfg(any(feature = "http1", feature = "http2"))] | ||||
| use tracing::trace; | ||||
|  | ||||
| use crate::common::io::Rewind; | ||||
| use crate::common::{task, Future, Pin, Poll}; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user