mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: test tracer (#6025)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
32
book/cli/reth/init.md
vendored
32
book/cli/reth/init.md
vendored
@ -56,37 +56,56 @@ Database:
|
||||
- extra: Enables logging for extra debug-level messages
|
||||
|
||||
Logging:
|
||||
--log.stdout.format <FORMAT>
|
||||
The format to use for logs written to stdout.
|
||||
|
||||
[default: terminal]
|
||||
|
||||
Possible values:
|
||||
- json
|
||||
- logfmt
|
||||
- terminal
|
||||
|
||||
--log.stdout.filter <FILTER>
|
||||
The filter to use for logs written to stdout.
|
||||
|
||||
[default: info]
|
||||
|
||||
--log.file.directory <PATH>
|
||||
The path to put log files in
|
||||
|
||||
[default: <CACHE_DIR>/logs]
|
||||
|
||||
--log.file.max-size <SIZE>
|
||||
The maximum size (in MB) of one log file
|
||||
|
||||
[default: 200]
|
||||
|
||||
--log.file.max-files <COUNT>
|
||||
The maximum amount of log files that will be stored. If set to 0, background file logging is disabled
|
||||
|
||||
[default: 5]
|
||||
|
||||
--log.file.filter <FILTER>
|
||||
The filter to use for logs written to the log file
|
||||
|
||||
[default: debug]
|
||||
|
||||
--log.file.format <FORMAT>
|
||||
The format to use for logs written to the log file.
|
||||
|
||||
[default: Terminal]
|
||||
|
||||
Possible values:
|
||||
- json
|
||||
- logfmt
|
||||
- terminal
|
||||
|
||||
--log.journald
|
||||
Write logs to journald
|
||||
|
||||
--log.journald.filter <FILTER>
|
||||
The filter to use for logs written to journald
|
||||
|
||||
[default: error]
|
||||
|
||||
--color <COLOR>
|
||||
Sets whether or not the formatter emits ANSI terminal escape codes for colors and other text formatting
|
||||
|
||||
[default: always]
|
||||
|
||||
Possible values:
|
||||
@ -97,7 +116,6 @@ Logging:
|
||||
Display:
|
||||
-v, --verbosity...
|
||||
Set the minimum log level.
|
||||
|
||||
-v Errors
|
||||
-vv Warnings
|
||||
-vvv Info
|
||||
|
||||
@ -12,7 +12,6 @@ use crate::{
|
||||
use core::sync::atomic::Ordering;
|
||||
use fnv::FnvHashMap;
|
||||
use futures::{stream::Fuse, SinkExt, StreamExt};
|
||||
|
||||
use reth_eth_wire::{
|
||||
capability::Capabilities,
|
||||
errors::{EthHandshakeError, EthStreamError, P2PStreamError},
|
||||
|
||||
@ -1292,10 +1292,10 @@ mod tests {
|
||||
use reth_network_api::NetworkInfo;
|
||||
use reth_primitives::hex;
|
||||
use reth_provider::test_utils::NoopProvider;
|
||||
|
||||
use reth_transaction_pool::test_utils::{testing_pool, MockTransaction};
|
||||
use secp256k1::SecretKey;
|
||||
use std::future::poll_fn;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_ignored_tx_broadcasts_while_initially_syncing() {
|
||||
reth_tracing::init_test_tracing();
|
||||
|
||||
@ -12,7 +12,6 @@ use reth_transaction_pool::{
|
||||
TransactionPool,
|
||||
};
|
||||
use tokio::sync::oneshot;
|
||||
|
||||
// peer0: `GetPooledTransactions` requestor
|
||||
// peer1: `GetPooledTransactions` responder
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
|
||||
@ -21,7 +21,6 @@ use reth_transaction_pool::test_utils::testing_pool;
|
||||
use secp256k1::SecretKey;
|
||||
use std::{collections::HashSet, net::SocketAddr, time::Duration};
|
||||
use tokio::task;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_establish_connections() {
|
||||
reth_tracing::init_test_tracing();
|
||||
|
||||
@ -13,7 +13,6 @@ use reth_primitives::{ChainSpec, Genesis, PeerId, SealedHeader};
|
||||
use reth_provider::test_utils::NoopProvider;
|
||||
use secp256k1::SecretKey;
|
||||
use std::{net::SocketAddr, sync::Arc};
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
#[cfg_attr(not(feature = "geth-tests"), ignore)]
|
||||
async fn can_peer_with_geth() {
|
||||
|
||||
@ -5,7 +5,6 @@ use reth_network::test_utils::Testnet;
|
||||
use reth_primitives::U256;
|
||||
use reth_provider::test_utils::{ExtendedAccount, MockEthProvider};
|
||||
use reth_transaction_pool::{test_utils::TransactionGenerator, PoolTransaction, TransactionPool};
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_tx_gossip() {
|
||||
reth_tracing::init_test_tracing();
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
|
||||
use tracing_subscriber::{filter::Directive, EnvFilter};
|
||||
use tracing_subscriber::filter::Directive;
|
||||
|
||||
// Re-export tracing crates
|
||||
pub use tracing;
|
||||
@ -52,8 +52,11 @@ pub use tracing_subscriber;
|
||||
pub use formatter::LogFormat;
|
||||
pub use layers::{FileInfo, FileWorkerGuard};
|
||||
|
||||
pub use test_tracer::TestTracer;
|
||||
|
||||
mod formatter;
|
||||
mod layers;
|
||||
mod test_tracer;
|
||||
|
||||
use crate::layers::Layers;
|
||||
use tracing::level_filters::LevelFilter;
|
||||
@ -223,8 +226,5 @@ impl Tracer for RethTracer {
|
||||
///
|
||||
/// The subscriber will silently fail if it could not be installed.
|
||||
pub fn init_test_tracing() {
|
||||
let _ = tracing_subscriber::fmt()
|
||||
.with_env_filter(EnvFilter::from_default_env())
|
||||
.with_writer(std::io::stderr)
|
||||
.try_init();
|
||||
let _ = TestTracer::default().init();
|
||||
}
|
||||
|
||||
25
crates/tracing/src/test_tracer.rs
Normal file
25
crates/tracing/src/test_tracer.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use tracing_appender::non_blocking::WorkerGuard;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
use crate::Tracer;
|
||||
|
||||
/// Initializes a tracing subscriber for tests.
|
||||
///
|
||||
/// The filter is configurable via `RUST_LOG`.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// The subscriber will silently fail if it could not be installed.
|
||||
#[derive(Debug, Clone, Default)]
|
||||
#[non_exhaustive]
|
||||
pub struct TestTracer;
|
||||
|
||||
impl Tracer for TestTracer {
|
||||
fn init(self) -> eyre::Result<Option<WorkerGuard>> {
|
||||
let _ = tracing_subscriber::fmt()
|
||||
.with_env_filter(EnvFilter::from_default_env())
|
||||
.with_writer(std::io::stderr)
|
||||
.try_init();
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user