From 9d53a0cdeccfa512d5d4a5c3977a3c879c2fe8c3 Mon Sep 17 00:00:00 2001 From: ThreeHrSleep Date: Fri, 4 Apr 2025 05:51:03 +0530 Subject: [PATCH 1/4] add padding after short levels --- common/logging/src/tracing_logging_layer.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/logging/src/tracing_logging_layer.rs b/common/logging/src/tracing_logging_layer.rs index 810f7e960e9..b303780594b 100644 --- a/common/logging/src/tracing_logging_layer.rs +++ b/common/logging/src/tracing_logging_layer.rs @@ -368,10 +368,12 @@ fn build_log_text<'a, S>( } } + let pad = if plain_level_str.len() < 5 { " " } else { "" }; + let level_str = if use_color { - color_level_str + format!("{}{}", color_level_str, pad) } else { - plain_level_str + format!("{}{}", plain_level_str, pad) }; let fixed_message_width = 44; From 87ef44f11af52b94ef1666e12831fa4802dbdd3a Mon Sep 17 00:00:00 2001 From: ThreeHrSleep Date: Fri, 4 Apr 2025 06:03:54 +0530 Subject: [PATCH 2/4] clippy --- crypto/bls/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/bls/src/lib.rs b/crypto/bls/src/lib.rs index 13b6dc2f2c7..ac2d83b2041 100644 --- a/crypto/bls/src/lib.rs +++ b/crypto/bls/src/lib.rs @@ -10,7 +10,7 @@ //! //! - `supranational`: the pure-assembly, highly optimized version from the `blst` crate. //! - `fake_crypto`: an always-returns-valid implementation that is only useful for testing -//! scenarios which intend to *ignore* real cryptography. +//! scenarios which intend to *ignore* real cryptography. //! //! This crate uses traits to reduce code-duplication between the two implementations. For example, //! the `GenericPublicKey` struct exported from this crate is generic across the `TPublicKey` trait From 4d3b134d6ef961655c98c629f3279d9e000376d6 Mon Sep 17 00:00:00 2001 From: ThreeHrSleep Date: Fri, 4 Apr 2025 06:17:50 +0530 Subject: [PATCH 3/4] Revert "clippy" This reverts commit 87ef44f11af52b94ef1666e12831fa4802dbdd3a. --- crypto/bls/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/bls/src/lib.rs b/crypto/bls/src/lib.rs index ac2d83b2041..13b6dc2f2c7 100644 --- a/crypto/bls/src/lib.rs +++ b/crypto/bls/src/lib.rs @@ -10,7 +10,7 @@ //! //! - `supranational`: the pure-assembly, highly optimized version from the `blst` crate. //! - `fake_crypto`: an always-returns-valid implementation that is only useful for testing -//! scenarios which intend to *ignore* real cryptography. +//! scenarios which intend to *ignore* real cryptography. //! //! This crate uses traits to reduce code-duplication between the two implementations. For example, //! the `GenericPublicKey` struct exported from this crate is generic across the `TPublicKey` trait From aeda558e3279401b8823387ae92a9b9f02628313 Mon Sep 17 00:00:00 2001 From: ThreeHrSleep Date: Sat, 5 Apr 2025 08:26:41 +0530 Subject: [PATCH 4/4] add width consts --- common/logging/src/tracing_logging_layer.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/common/logging/src/tracing_logging_layer.rs b/common/logging/src/tracing_logging_layer.rs index b303780594b..c3784a8f621 100644 --- a/common/logging/src/tracing_logging_layer.rs +++ b/common/logging/src/tracing_logging_layer.rs @@ -13,6 +13,9 @@ use tracing_subscriber::layer::Context; use tracing_subscriber::registry::LookupSpan; use tracing_subscriber::Layer; +const FIXED_MESSAGE_WIDTH: usize = 44; +const ALIGNED_LEVEL_WIDTH: usize = 5; + pub struct LoggingLayer { pub non_blocking_writer: NonBlocking, _guard: WorkerGuard, @@ -368,7 +371,11 @@ fn build_log_text<'a, S>( } } - let pad = if plain_level_str.len() < 5 { " " } else { "" }; + let pad = if plain_level_str.len() < ALIGNED_LEVEL_WIDTH { + " " + } else { + "" + }; let level_str = if use_color { format!("{}{}", color_level_str, pad) @@ -376,7 +383,6 @@ fn build_log_text<'a, S>( format!("{}{}", plain_level_str, pad) }; - let fixed_message_width = 44; let message_len = visitor.message.len(); let message_content = if use_color { @@ -385,7 +391,7 @@ fn build_log_text<'a, S>( visitor.message.clone() }; - let padded_message = if message_len < fixed_message_width { + let padded_message = if message_len < FIXED_MESSAGE_WIDTH { let extra_color_len = if use_color { bold_start.len() + bold_end.len() } else { @@ -394,7 +400,7 @@ fn build_log_text<'a, S>( format!( "{: