From 0cd70b053609ba5483a89d38fd45ef73e138bec2 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 15 Mar 2022 19:37:08 +0000 Subject: [PATCH] use tracing for logs (#451) --- actix-codec/CHANGES.md | 3 +++ actix-codec/Cargo.toml | 2 +- actix-codec/src/framed.rs | 10 +++++----- actix-tls/CHANGES.md | 3 +++ actix-tls/Cargo.toml | 2 +- actix-tls/examples/accept-rustls.rs | 2 +- actix-tls/src/connect/native_tls.rs | 2 +- actix-tls/src/connect/openssl.rs | 2 +- actix-tls/src/connect/resolver.rs | 2 +- actix-tls/src/connect/rustls.rs | 2 +- actix-tls/src/connect/tcp.rs | 2 +- 11 files changed, 19 insertions(+), 13 deletions(-) diff --git a/actix-codec/CHANGES.md b/actix-codec/CHANGES.md index 4f093de5..993e0dd0 100644 --- a/actix-codec/CHANGES.md +++ b/actix-codec/CHANGES.md @@ -1,8 +1,11 @@ # Changes ## Unreleased - 2022-xx-xx +- Logs emitted now use the `tracing` crate with `log` compatibility. [#451] - Minimum supported Rust version (MSRV) is now 1.49. +[#451]: https://github.com/actix/actix-net/pull/451 + ## 0.5.0 - 2022-02-15 - Updated `tokio-util` dependency to `0.7.0`. [#446] diff --git a/actix-codec/Cargo.toml b/actix-codec/Cargo.toml index abd45f34..f1f58860 100644 --- a/actix-codec/Cargo.toml +++ b/actix-codec/Cargo.toml @@ -21,11 +21,11 @@ bitflags = "1.2" bytes = "1" futures-core = { version = "0.3.7", default-features = false } futures-sink = { version = "0.3.7", default-features = false } -log = "0.4" memchr = "2.3" pin-project-lite = "0.2" tokio = "1.13.1" tokio-util = { version = "0.7", features = ["codec", "io"] } +tracing = { version = "0.1.30", default-features = false, features = ["log"] } [dev-dependencies] criterion = { version = "0.3", features = ["html_reports"] } diff --git a/actix-codec/src/framed.rs b/actix-codec/src/framed.rs index 73dca006..c03ea02d 100644 --- a/actix-codec/src/framed.rs +++ b/actix-codec/src/framed.rs @@ -197,11 +197,11 @@ impl Framed { } } - log::trace!("attempting to decode a frame"); + tracing::trace!("attempting to decode a frame"); match this.codec.decode(this.read_buf) { Ok(Some(frame)) => { - log::trace!("frame decoded from buffer"); + tracing::trace!("frame decoded from buffer"); return Poll::Ready(Some(Ok(frame))); } Err(err) => return Poll::Ready(Some(Err(err))), @@ -242,10 +242,10 @@ impl Framed { U: Encoder, { let mut this = self.as_mut().project(); - log::trace!("flushing framed transport"); + tracing::trace!("flushing framed transport"); 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))?; @@ -264,7 +264,7 @@ impl Framed { // Try flushing the underlying IO ready!(this.io.poll_flush(cx))?; - log::trace!("framed transport flushed"); + tracing::trace!("framed transport flushed"); Poll::Ready(Ok(())) } diff --git a/actix-tls/CHANGES.md b/actix-tls/CHANGES.md index f6978fbe..3915141c 100644 --- a/actix-tls/CHANGES.md +++ b/actix-tls/CHANGES.md @@ -1,6 +1,9 @@ # Changes ## 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 diff --git a/actix-tls/Cargo.toml b/actix-tls/Cargo.toml index b78c0e8b..43de2bff 100755 --- a/actix-tls/Cargo.toml +++ b/actix-tls/Cargo.toml @@ -48,9 +48,9 @@ actix-service = "2.0.0" actix-utils = "3.0.0" futures-core = { version = "0.3.7", default-features = false, features = ["alloc"] } -log = "0.4" pin-project-lite = "0.2.7" tokio-util = "0.7" +tracing = { version = "0.1.30", default-features = false, features = ["log"] } # uri http = { version = "0.2.3", optional = true } diff --git a/actix-tls/examples/accept-rustls.rs b/actix-tls/examples/accept-rustls.rs index a0550495..0ea1e7e1 100644 --- a/actix-tls/examples/accept-rustls.rs +++ b/actix-tls/examples/accept-rustls.rs @@ -34,9 +34,9 @@ use actix_server::Server; use actix_service::ServiceFactoryExt as _; use actix_tls::accept::rustls::{Acceptor as RustlsAcceptor, TlsStream}; use futures_util::future::ok; -use log::info; use rustls::{server::ServerConfig, Certificate, PrivateKey}; use rustls_pemfile::{certs, rsa_private_keys}; +use tracing::info; #[actix_rt::main] async fn main() -> io::Result<()> { diff --git a/actix-tls/src/connect/native_tls.rs b/actix-tls/src/connect/native_tls.rs index 49222228..74a24c22 100644 --- a/actix-tls/src/connect/native_tls.rs +++ b/actix-tls/src/connect/native_tls.rs @@ -8,11 +8,11 @@ use actix_rt::net::ActixStream; use actix_service::{Service, ServiceFactory}; use actix_utils::future::{ok, Ready}; use futures_core::future::LocalBoxFuture; -use log::trace; use tokio_native_tls::{ native_tls::TlsConnector as NativeTlsConnector, TlsConnector as AsyncNativeTlsConnector, TlsStream as AsyncTlsStream, }; +use tracing::trace; use crate::connect::{Connection, Host}; diff --git a/actix-tls/src/connect/openssl.rs b/actix-tls/src/connect/openssl.rs index 5739f6bc..5558baed 100644 --- a/actix-tls/src/connect/openssl.rs +++ b/actix-tls/src/connect/openssl.rs @@ -13,9 +13,9 @@ use actix_rt::net::ActixStream; use actix_service::{Service, ServiceFactory}; use actix_utils::future::{ok, Ready}; use futures_core::ready; -use log::trace; use openssl::ssl::SslConnector; use tokio_openssl::SslStream as AsyncSslStream; +use tracing::trace; use crate::connect::{Connection, Host}; diff --git a/actix-tls/src/connect/resolver.rs b/actix-tls/src/connect/resolver.rs index 245f919c..5ab5f475 100644 --- a/actix-tls/src/connect/resolver.rs +++ b/actix-tls/src/connect/resolver.rs @@ -12,7 +12,7 @@ use actix_rt::task::{spawn_blocking, JoinHandle}; use actix_service::{Service, ServiceFactory}; use actix_utils::future::{ok, Ready}; use futures_core::{future::LocalBoxFuture, ready}; -use log::trace; +use tracing::trace; use super::{ConnectError, ConnectInfo, Host, Resolve}; diff --git a/actix-tls/src/connect/rustls.rs b/actix-tls/src/connect/rustls.rs index 641ddd23..8d74fd8a 100644 --- a/actix-tls/src/connect/rustls.rs +++ b/actix-tls/src/connect/rustls.rs @@ -15,10 +15,10 @@ use actix_rt::net::ActixStream; use actix_service::{Service, ServiceFactory}; use actix_utils::future::{ok, Ready}; use futures_core::ready; -use log::trace; use tokio_rustls::rustls::{client::ServerName, OwnedTrustAnchor, RootCertStore}; use tokio_rustls::{client::TlsStream as AsyncTlsStream, rustls::ClientConfig}; use tokio_rustls::{Connect as RustlsConnect, TlsConnector as RustlsTlsConnector}; +use tracing::trace; use webpki_roots::TLS_SERVER_ROOTS; use crate::connect::{Connection, Host}; diff --git a/actix-tls/src/connect/tcp.rs b/actix-tls/src/connect/tcp.rs index e2bc749a..b102620c 100644 --- a/actix-tls/src/connect/tcp.rs +++ b/actix-tls/src/connect/tcp.rs @@ -15,8 +15,8 @@ use actix_rt::net::{TcpSocket, TcpStream}; use actix_service::{Service, ServiceFactory}; use actix_utils::future::{ok, Ready}; use futures_core::ready; -use log::{error, trace}; use tokio_util::sync::ReusableBoxFuture; +use tracing::{error, trace}; use super::{connect_addrs::ConnectAddrs, error::ConnectError, ConnectInfo, Connection, Host};