Tracing cleanup (#7168)

#7153
#7146
#7147
#7148 -> Thanks to @ackintosh


  This PR does the following:
1. Disable logging to file when using either `--logfile-max-number 0` or `--logfile-max-size 0`. Note that disabling the log file in this way will also disable `discv5` and `libp2p` logging.
1.  `discv5` and `libp2p` logging will be disabled by default unless running `beacon_node` or `boot_node`. This also should fix the VC panic we were seeing.
1. Removes log rotation and compression from `libp2p` and `discv5` logs. It is now limited to 1 file and will rotate based on the value of the `--logfile-max-size` flag. We could potentially add flags specifically to control the size/number of these, however I felt a single log file was sufficient. Perhaps @AgeManning has opinions about this?
1. Removes all dependency logging and references to `dep_log`.
1.  Introduces workspace filtering to file and stdout. This explicitly allows logs from members of the Lighthouse workspace, disallowing all others. It uses a proc macro which pulls the member list from cargo metadata at compile time. This might be over-engineered but my hope is that this list will not require maintenance.
1. Unifies file and stdout JSON format. With slog, the formats were slightly different. @threehrsleep worked to maintain that format difference, to ensure there was no breaking changes. If these format differences are actually problematic we can restore it, however I felt the added complexity wasn't worth it.
1. General code improvements and cleanup.
This commit is contained in:
Mac L
2025-04-01 21:51:09 +11:00
committed by GitHub
parent fb7ec0d151
commit 4839ed620f
14 changed files with 382 additions and 365 deletions

View File

@@ -15,7 +15,6 @@ use std::sync::Arc;
use std::time::Duration;
use environment::tracing_common;
use logging::MetricsLayer;
use tracing_subscriber::prelude::*;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
@@ -90,12 +89,11 @@ pub fn run_basic_sim(matches: &ArgMatches) -> Result<(), String> {
let (
env_builder,
_libp2p_discv5_layer,
file_logging_layer,
stdout_logging_layer,
_sse_logging_layer_opt,
logger_config,
_dependency_log_filter,
stdout_logging_layer,
_file_logging_layer,
_sse_logging_layer_opt,
_libp2p_discv5_layer,
) = tracing_common::construct_logger(
LoggerConfig {
path: None,
@@ -118,9 +116,7 @@ pub fn run_basic_sim(matches: &ArgMatches) -> Result<(), String> {
);
if let Err(e) = tracing_subscriber::registry()
.with(file_logging_layer.with_filter(logger_config.logfile_debug_level))
.with(stdout_logging_layer.with_filter(logger_config.debug_level))
.with(MetricsLayer)
.try_init()
{
eprintln!("Failed to initialize dependency logging: {e}");

View File

@@ -5,7 +5,6 @@ use clap::ArgMatches;
use crate::retry::with_retry;
use environment::tracing_common;
use futures::prelude::*;
use logging::MetricsLayer;
use node_test_rig::{
environment::{EnvironmentBuilder, LoggerConfig},
testing_validator_config, ValidatorFiles,
@@ -94,12 +93,11 @@ pub fn run_fallback_sim(matches: &ArgMatches) -> Result<(), String> {
let (
env_builder,
libp2p_discv5_layer,
file_logging_layer,
stdout_logging_layer,
_sse_logging_layer_opt,
logger_config,
dependency_log_filter,
stdout_logging_layer,
_file_logging_layer,
_sse_logging_layer_opt,
_libp2p_discv5_layer,
) = tracing_common::construct_logger(
LoggerConfig {
path: None,
@@ -122,11 +120,7 @@ pub fn run_fallback_sim(matches: &ArgMatches) -> Result<(), String> {
);
if let Err(e) = tracing_subscriber::registry()
.with(dependency_log_filter)
.with(file_logging_layer.with_filter(logger_config.logfile_debug_level))
.with(stdout_logging_layer.with_filter(logger_config.debug_level))
.with(libp2p_discv5_layer)
.with(MetricsLayer)
.try_init()
{
eprintln!("Failed to initialize dependency logging: {e}");