diff --git a/actix-server/Cargo.toml b/actix-server/Cargo.toml index a5781777..bf6a9efa 100755 --- a/actix-server/Cargo.toml +++ b/actix-server/Cargo.toml @@ -30,11 +30,11 @@ actix-utils = "3.0.0" futures-core = { version = "0.3.7", default-features = false, features = ["alloc"] } futures-util = { version = "0.3.7", default-features = false, features = ["alloc"] } -log = "0.4" mio = { version = "0.8", features = ["os-poll", "net"] } num_cpus = "1.13" socket2 = "0.4.2" tokio = { version = "1.13.1", features = ["sync"] } +tracing = { version = "0.1.30", features = ["log"] } # runtime for io-uring feature [target.'cfg(target_os = "linux")'.dependencies] diff --git a/actix-server/examples/file-reader.rs b/actix-server/examples/file-reader.rs index 3cc991d3..63f6529a 100644 --- a/actix-server/examples/file-reader.rs +++ b/actix-server/examples/file-reader.rs @@ -21,7 +21,7 @@ async fn run() -> io::Result<()> { env_logger::init_from_env(env_logger::Env::default().default_filter_or("info")); let addr = ("127.0.0.1", 8080); - log::info!("starting server on port: {}", &addr.0); + tracing::info!("starting server on port: {}", &addr.0); // Bind socket address and start worker(s). By default, the server uses the number of physical // CPU cores as the worker count. For this reason, the closure passed to bind needs to return @@ -52,7 +52,7 @@ async fn run() -> io::Result<()> { break; } Err(err) => { - log::error!("{}", err); + tracing::error!("{}", err); framed .send("File not found or not readable. Try again.") .await?; @@ -72,7 +72,7 @@ async fn run() -> io::Result<()> { // close connection after file has been copied to TCP stream Ok(()) }) - .map_err(|err| log::error!("Service Error: {:?}", err)) + .map_err(|err| tracing::error!("Service Error: {:?}", err)) })? .workers(2) .run() diff --git a/actix-server/examples/tcp-echo.rs b/actix-server/examples/tcp-echo.rs index da0b7053..0bf819c7 100644 --- a/actix-server/examples/tcp-echo.rs +++ b/actix-server/examples/tcp-echo.rs @@ -22,8 +22,8 @@ use actix_server::Server; use actix_service::{fn_service, ServiceFactoryExt as _}; use bytes::BytesMut; use futures_util::future::ok; -use log::{error, info}; use tokio::io::{AsyncReadExt as _, AsyncWriteExt as _}; +use tracing::{error, info}; async fn run() -> io::Result<()> { env_logger::init_from_env(env_logger::Env::default().default_filter_or("info")); diff --git a/actix-server/src/accept.rs b/actix-server/src/accept.rs index a1c4f732..a5c8225d 100644 --- a/actix-server/src/accept.rs +++ b/actix-server/src/accept.rs @@ -1,8 +1,8 @@ use std::{io, thread, time::Duration}; use actix_rt::time::Instant; -use log::{debug, error, info}; use mio::{Interest, Poll, Token as MioToken}; +use tracing::{debug, error, info}; use crate::{ availability::Availability, diff --git a/actix-server/src/builder.rs b/actix-server/src/builder.rs index c3bc0269..8660b4a9 100644 --- a/actix-server/src/builder.rs +++ b/actix-server/src/builder.rs @@ -1,8 +1,8 @@ use std::{io, time::Duration}; use actix_rt::net::TcpStream; -use log::{info, trace}; use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender}; +use tracing::{info, trace}; use crate::{ server::ServerCommand, diff --git a/actix-server/src/server.rs b/actix-server/src/server.rs index 8defa543..3e0d7733 100644 --- a/actix-server/src/server.rs +++ b/actix-server/src/server.rs @@ -10,8 +10,8 @@ use std::{ use actix_rt::{time::sleep, System}; use futures_core::{future::BoxFuture, Stream}; use futures_util::stream::StreamExt as _; -use log::{error, info}; use tokio::sync::{mpsc::UnboundedReceiver, oneshot}; +use tracing::{error, info}; use crate::{ accept::Accept, diff --git a/actix-server/src/service.rs b/actix-server/src/service.rs index 3a9aeee4..03ee72d5 100644 --- a/actix-server/src/service.rs +++ b/actix-server/src/service.rs @@ -7,7 +7,7 @@ use std::{ use actix_service::{Service, ServiceFactory as BaseServiceFactory}; use actix_utils::future::{ready, Ready}; use futures_core::future::LocalBoxFuture; -use log::error; +use tracing::error; use crate::{ socket::{FromStream, MioStream}, diff --git a/actix-server/src/signals.rs b/actix-server/src/signals.rs index d8cb84e3..91bd52cc 100644 --- a/actix-server/src/signals.rs +++ b/actix-server/src/signals.rs @@ -5,7 +5,7 @@ use std::{ task::{Context, Poll}, }; -use log::trace; +use tracing::trace; /// Types of process signals. // #[allow(dead_code)] @@ -69,7 +69,7 @@ impl Signals { unix::signal(*kind) .map(|tokio_sig| (*sig, tokio_sig)) .map_err(|e| { - log::error!( + tracing::error!( "Can not initialize stream handler for {:?} err: {}", sig, e diff --git a/actix-server/src/worker.rs b/actix-server/src/worker.rs index 2fef9a7b..b66ea4b9 100644 --- a/actix-server/src/worker.rs +++ b/actix-server/src/worker.rs @@ -17,11 +17,11 @@ use actix_rt::{ Arbiter, ArbiterHandle, System, }; use futures_core::{future::LocalBoxFuture, ready}; -use log::{error, info, trace}; use tokio::sync::{ mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender}, oneshot, }; +use tracing::{error, info, trace}; use crate::{ service::{BoxedServerService, InternalServiceFactory}, diff --git a/actix-server/tests/server.rs b/actix-server/tests/server.rs index 0a70402b..ec3155c9 100644 --- a/actix-server/tests/server.rs +++ b/actix-server/tests/server.rs @@ -254,6 +254,7 @@ async fn test_max_concurrent_connections() { h.join().unwrap().unwrap(); } +// TODO: race-y failures detected due to integer underflow when calling Counter::total #[actix_rt::test] async fn test_service_restart() { use std::task::{Context, Poll};