mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-23 22:51:07 +01:00
add tracing support
This commit is contained in:
parent
77d4a69b2f
commit
c5d6174cec
@ -30,11 +30,11 @@ 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"] }
|
||||||
futures-util = { 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"] }
|
mio = { version = "0.8", features = ["os-poll", "net"] }
|
||||||
num_cpus = "1.13"
|
num_cpus = "1.13"
|
||||||
socket2 = "0.4.2"
|
socket2 = "0.4.2"
|
||||||
tokio = { version = "1.13.1", features = ["sync"] }
|
tokio = { version = "1.13.1", features = ["sync"] }
|
||||||
|
tracing = { version = "0.1.30", features = ["log"] }
|
||||||
|
|
||||||
# runtime for io-uring feature
|
# runtime for io-uring feature
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
|
@ -21,7 +21,7 @@ async fn run() -> io::Result<()> {
|
|||||||
env_logger::init_from_env(env_logger::Env::default().default_filter_or("info"));
|
env_logger::init_from_env(env_logger::Env::default().default_filter_or("info"));
|
||||||
|
|
||||||
let addr = ("127.0.0.1", 8080);
|
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
|
// 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
|
// 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;
|
break;
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
log::error!("{}", err);
|
tracing::error!("{}", err);
|
||||||
framed
|
framed
|
||||||
.send("File not found or not readable. Try again.")
|
.send("File not found or not readable. Try again.")
|
||||||
.await?;
|
.await?;
|
||||||
@ -72,7 +72,7 @@ async fn run() -> io::Result<()> {
|
|||||||
// close connection after file has been copied to TCP stream
|
// close connection after file has been copied to TCP stream
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.map_err(|err| log::error!("Service Error: {:?}", err))
|
.map_err(|err| tracing::error!("Service Error: {:?}", err))
|
||||||
})?
|
})?
|
||||||
.workers(2)
|
.workers(2)
|
||||||
.run()
|
.run()
|
||||||
|
@ -22,8 +22,8 @@ use actix_server::Server;
|
|||||||
use actix_service::{fn_service, ServiceFactoryExt as _};
|
use actix_service::{fn_service, ServiceFactoryExt as _};
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
use futures_util::future::ok;
|
use futures_util::future::ok;
|
||||||
use log::{error, info};
|
|
||||||
use tokio::io::{AsyncReadExt as _, AsyncWriteExt as _};
|
use tokio::io::{AsyncReadExt as _, AsyncWriteExt as _};
|
||||||
|
use tracing::{error, info};
|
||||||
|
|
||||||
async fn run() -> io::Result<()> {
|
async fn run() -> io::Result<()> {
|
||||||
env_logger::init_from_env(env_logger::Env::default().default_filter_or("info"));
|
env_logger::init_from_env(env_logger::Env::default().default_filter_or("info"));
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use std::{io, thread, time::Duration};
|
use std::{io, thread, time::Duration};
|
||||||
|
|
||||||
use actix_rt::time::Instant;
|
use actix_rt::time::Instant;
|
||||||
use log::{debug, error, info};
|
|
||||||
use mio::{Interest, Poll, Token as MioToken};
|
use mio::{Interest, Poll, Token as MioToken};
|
||||||
|
use tracing::{debug, error, info};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
availability::Availability,
|
availability::Availability,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use std::{io, time::Duration};
|
use std::{io, time::Duration};
|
||||||
|
|
||||||
use actix_rt::net::TcpStream;
|
use actix_rt::net::TcpStream;
|
||||||
use log::{info, trace};
|
|
||||||
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender};
|
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender};
|
||||||
|
use tracing::{info, trace};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
server::ServerCommand,
|
server::ServerCommand,
|
||||||
|
@ -10,8 +10,8 @@ use std::{
|
|||||||
use actix_rt::{time::sleep, System};
|
use actix_rt::{time::sleep, System};
|
||||||
use futures_core::{future::BoxFuture, Stream};
|
use futures_core::{future::BoxFuture, Stream};
|
||||||
use futures_util::stream::StreamExt as _;
|
use futures_util::stream::StreamExt as _;
|
||||||
use log::{error, info};
|
|
||||||
use tokio::sync::{mpsc::UnboundedReceiver, oneshot};
|
use tokio::sync::{mpsc::UnboundedReceiver, oneshot};
|
||||||
|
use tracing::{error, info};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
accept::Accept,
|
accept::Accept,
|
||||||
|
@ -7,7 +7,7 @@ use std::{
|
|||||||
use actix_service::{Service, ServiceFactory as BaseServiceFactory};
|
use actix_service::{Service, ServiceFactory as BaseServiceFactory};
|
||||||
use actix_utils::future::{ready, Ready};
|
use actix_utils::future::{ready, Ready};
|
||||||
use futures_core::future::LocalBoxFuture;
|
use futures_core::future::LocalBoxFuture;
|
||||||
use log::error;
|
use tracing::error;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
socket::{FromStream, MioStream},
|
socket::{FromStream, MioStream},
|
||||||
|
@ -5,7 +5,7 @@ use std::{
|
|||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
};
|
};
|
||||||
|
|
||||||
use log::trace;
|
use tracing::trace;
|
||||||
|
|
||||||
/// Types of process signals.
|
/// Types of process signals.
|
||||||
// #[allow(dead_code)]
|
// #[allow(dead_code)]
|
||||||
@ -69,7 +69,7 @@ impl Signals {
|
|||||||
unix::signal(*kind)
|
unix::signal(*kind)
|
||||||
.map(|tokio_sig| (*sig, tokio_sig))
|
.map(|tokio_sig| (*sig, tokio_sig))
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
log::error!(
|
tracing::error!(
|
||||||
"Can not initialize stream handler for {:?} err: {}",
|
"Can not initialize stream handler for {:?} err: {}",
|
||||||
sig,
|
sig,
|
||||||
e
|
e
|
||||||
|
@ -17,11 +17,11 @@ use actix_rt::{
|
|||||||
Arbiter, ArbiterHandle, System,
|
Arbiter, ArbiterHandle, System,
|
||||||
};
|
};
|
||||||
use futures_core::{future::LocalBoxFuture, ready};
|
use futures_core::{future::LocalBoxFuture, ready};
|
||||||
use log::{error, info, trace};
|
|
||||||
use tokio::sync::{
|
use tokio::sync::{
|
||||||
mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender},
|
mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender},
|
||||||
oneshot,
|
oneshot,
|
||||||
};
|
};
|
||||||
|
use tracing::{error, info, trace};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
service::{BoxedServerService, InternalServiceFactory},
|
service::{BoxedServerService, InternalServiceFactory},
|
||||||
|
@ -254,6 +254,7 @@ async fn test_max_concurrent_connections() {
|
|||||||
h.join().unwrap().unwrap();
|
h.join().unwrap().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: race-y failures detected due to integer underflow when calling Counter::total
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_service_restart() {
|
async fn test_service_restart() {
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
Loading…
Reference in New Issue
Block a user