1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-30 17:44:34 +01:00

use tracing for logs (#451)

This commit is contained in:
Rob Ede 2022-03-15 19:37:08 +00:00 committed by GitHub
parent 4b6a581ef3
commit 0cd70b0536
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 19 additions and 13 deletions

View File

@ -1,8 +1,11 @@
# Changes # Changes
## Unreleased - 2022-xx-xx ## Unreleased - 2022-xx-xx
- Logs emitted now use the `tracing` crate with `log` compatibility. [#451]
- Minimum supported Rust version (MSRV) is now 1.49. - Minimum supported Rust version (MSRV) is now 1.49.
[#451]: https://github.com/actix/actix-net/pull/451
## 0.5.0 - 2022-02-15 ## 0.5.0 - 2022-02-15
- Updated `tokio-util` dependency to `0.7.0`. [#446] - Updated `tokio-util` dependency to `0.7.0`. [#446]

View File

@ -21,11 +21,11 @@ bitflags = "1.2"
bytes = "1" bytes = "1"
futures-core = { version = "0.3.7", default-features = false } futures-core = { version = "0.3.7", default-features = false }
futures-sink = { version = "0.3.7", default-features = false } futures-sink = { version = "0.3.7", default-features = false }
log = "0.4"
memchr = "2.3" memchr = "2.3"
pin-project-lite = "0.2" pin-project-lite = "0.2"
tokio = "1.13.1" tokio = "1.13.1"
tokio-util = { version = "0.7", features = ["codec", "io"] } tokio-util = { version = "0.7", features = ["codec", "io"] }
tracing = { version = "0.1.30", default-features = false, features = ["log"] }
[dev-dependencies] [dev-dependencies]
criterion = { version = "0.3", features = ["html_reports"] } criterion = { version = "0.3", features = ["html_reports"] }

View File

@ -197,11 +197,11 @@ impl<T, U> Framed<T, U> {
} }
} }
log::trace!("attempting to decode a frame"); tracing::trace!("attempting to decode a frame");
match this.codec.decode(this.read_buf) { match this.codec.decode(this.read_buf) {
Ok(Some(frame)) => { Ok(Some(frame)) => {
log::trace!("frame decoded from buffer"); tracing::trace!("frame decoded from buffer");
return Poll::Ready(Some(Ok(frame))); return Poll::Ready(Some(Ok(frame)));
} }
Err(err) => return Poll::Ready(Some(Err(err))), Err(err) => return Poll::Ready(Some(Err(err))),
@ -242,10 +242,10 @@ impl<T, U> Framed<T, U> {
U: Encoder<I>, U: Encoder<I>,
{ {
let mut this = self.as_mut().project(); let mut this = self.as_mut().project();
log::trace!("flushing framed transport"); tracing::trace!("flushing framed transport");
while !this.write_buf.is_empty() { while !this.write_buf.is_empty() {
log::trace!("writing; remaining={}", this.write_buf.len()); tracing::trace!("writing; remaining={}", this.write_buf.len());
let n = ready!(this.io.as_mut().poll_write(cx, this.write_buf))?; let n = ready!(this.io.as_mut().poll_write(cx, this.write_buf))?;
@ -264,7 +264,7 @@ impl<T, U> Framed<T, U> {
// Try flushing the underlying IO // Try flushing the underlying IO
ready!(this.io.poll_flush(cx))?; ready!(this.io.poll_flush(cx))?;
log::trace!("framed transport flushed"); tracing::trace!("framed transport flushed");
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }

View File

@ -1,6 +1,9 @@
# Changes # Changes
## Unreleased - 2022-xx-xx ## Unreleased - 2022-xx-xx
- Logs emitted now use the `tracing` crate with `log` compatibility. [#451]
[#451]: https://github.com/actix/actix-net/pull/451
## 3.0.3 - 2022-02-15 ## 3.0.3 - 2022-02-15

View File

@ -48,9 +48,9 @@ actix-service = "2.0.0"
actix-utils = "3.0.0" actix-utils = "3.0.0"
futures-core = { version = "0.3.7", default-features = false, features = ["alloc"] } futures-core = { version = "0.3.7", default-features = false, features = ["alloc"] }
log = "0.4"
pin-project-lite = "0.2.7" pin-project-lite = "0.2.7"
tokio-util = "0.7" tokio-util = "0.7"
tracing = { version = "0.1.30", default-features = false, features = ["log"] }
# uri # uri
http = { version = "0.2.3", optional = true } http = { version = "0.2.3", optional = true }

View File

@ -34,9 +34,9 @@ use actix_server::Server;
use actix_service::ServiceFactoryExt as _; use actix_service::ServiceFactoryExt as _;
use actix_tls::accept::rustls::{Acceptor as RustlsAcceptor, TlsStream}; use actix_tls::accept::rustls::{Acceptor as RustlsAcceptor, TlsStream};
use futures_util::future::ok; use futures_util::future::ok;
use log::info;
use rustls::{server::ServerConfig, Certificate, PrivateKey}; use rustls::{server::ServerConfig, Certificate, PrivateKey};
use rustls_pemfile::{certs, rsa_private_keys}; use rustls_pemfile::{certs, rsa_private_keys};
use tracing::info;
#[actix_rt::main] #[actix_rt::main]
async fn main() -> io::Result<()> { async fn main() -> io::Result<()> {

View File

@ -8,11 +8,11 @@ use actix_rt::net::ActixStream;
use actix_service::{Service, ServiceFactory}; use actix_service::{Service, ServiceFactory};
use actix_utils::future::{ok, Ready}; use actix_utils::future::{ok, Ready};
use futures_core::future::LocalBoxFuture; use futures_core::future::LocalBoxFuture;
use log::trace;
use tokio_native_tls::{ use tokio_native_tls::{
native_tls::TlsConnector as NativeTlsConnector, TlsConnector as AsyncNativeTlsConnector, native_tls::TlsConnector as NativeTlsConnector, TlsConnector as AsyncNativeTlsConnector,
TlsStream as AsyncTlsStream, TlsStream as AsyncTlsStream,
}; };
use tracing::trace;
use crate::connect::{Connection, Host}; use crate::connect::{Connection, Host};

View File

@ -13,9 +13,9 @@ use actix_rt::net::ActixStream;
use actix_service::{Service, ServiceFactory}; use actix_service::{Service, ServiceFactory};
use actix_utils::future::{ok, Ready}; use actix_utils::future::{ok, Ready};
use futures_core::ready; use futures_core::ready;
use log::trace;
use openssl::ssl::SslConnector; use openssl::ssl::SslConnector;
use tokio_openssl::SslStream as AsyncSslStream; use tokio_openssl::SslStream as AsyncSslStream;
use tracing::trace;
use crate::connect::{Connection, Host}; use crate::connect::{Connection, Host};

View File

@ -12,7 +12,7 @@ use actix_rt::task::{spawn_blocking, JoinHandle};
use actix_service::{Service, ServiceFactory}; use actix_service::{Service, ServiceFactory};
use actix_utils::future::{ok, Ready}; use actix_utils::future::{ok, Ready};
use futures_core::{future::LocalBoxFuture, ready}; use futures_core::{future::LocalBoxFuture, ready};
use log::trace; use tracing::trace;
use super::{ConnectError, ConnectInfo, Host, Resolve}; use super::{ConnectError, ConnectInfo, Host, Resolve};

View File

@ -15,10 +15,10 @@ use actix_rt::net::ActixStream;
use actix_service::{Service, ServiceFactory}; use actix_service::{Service, ServiceFactory};
use actix_utils::future::{ok, Ready}; use actix_utils::future::{ok, Ready};
use futures_core::ready; use futures_core::ready;
use log::trace;
use tokio_rustls::rustls::{client::ServerName, OwnedTrustAnchor, RootCertStore}; use tokio_rustls::rustls::{client::ServerName, OwnedTrustAnchor, RootCertStore};
use tokio_rustls::{client::TlsStream as AsyncTlsStream, rustls::ClientConfig}; use tokio_rustls::{client::TlsStream as AsyncTlsStream, rustls::ClientConfig};
use tokio_rustls::{Connect as RustlsConnect, TlsConnector as RustlsTlsConnector}; use tokio_rustls::{Connect as RustlsConnect, TlsConnector as RustlsTlsConnector};
use tracing::trace;
use webpki_roots::TLS_SERVER_ROOTS; use webpki_roots::TLS_SERVER_ROOTS;
use crate::connect::{Connection, Host}; use crate::connect::{Connection, Host};

View File

@ -15,8 +15,8 @@ use actix_rt::net::{TcpSocket, TcpStream};
use actix_service::{Service, ServiceFactory}; use actix_service::{Service, ServiceFactory};
use actix_utils::future::{ok, Ready}; use actix_utils::future::{ok, Ready};
use futures_core::ready; use futures_core::ready;
use log::{error, trace};
use tokio_util::sync::ReusableBoxFuture; use tokio_util::sync::ReusableBoxFuture;
use tracing::{error, trace};
use super::{connect_addrs::ConnectAddrs, error::ConnectError, ConnectInfo, Connection, Host}; use super::{connect_addrs::ConnectAddrs, error::ConnectError, ConnectInfo, Connection, Host};