From e6ca9eba875be723c0cd39b03734875730c815b0 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sun, 26 Apr 2026 17:36:03 -0400 Subject: [PATCH] refactor(cli): rename ServerLogSink to LogSink The Server prefix is redundant -- the type is used by both Server and Worker variants of InternalLogSink, and the helper that builds it from a runtime directory is renamed to log_sink to match. Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/crates/fabro-cli/src/logging.rs | 14 +++++++------- lib/crates/fabro-cli/src/main.rs | 24 ++++++++++++------------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/crates/fabro-cli/src/logging.rs b/lib/crates/fabro-cli/src/logging.rs index f69b0fa9a..03fabe7b5 100644 --- a/lib/crates/fabro-cli/src/logging.rs +++ b/lib/crates/fabro-cli/src/logging.rs @@ -17,7 +17,7 @@ use tracing_subscriber::{EnvFilter, fmt}; const LOG_RETENTION_DAYS: u32 = 7; #[derive(Clone, Debug, PartialEq, Eq)] -pub(crate) enum ServerLogSink { +pub(crate) enum LogSink { File(PathBuf), Stdout, } @@ -26,10 +26,10 @@ pub(crate) enum ServerLogSink { pub(crate) enum InternalLogSink { Cli, Server { - log: ServerLogSink, + log: LogSink, }, Worker { - server_log: ServerLogSink, + server_log: LogSink, per_run_log_path: PathBuf, }, } @@ -66,17 +66,17 @@ pub(crate) fn init_tracing( init_subscriber(filter, file_appender); } InternalLogSink::Server { - log: ServerLogSink::File(path), + log: LogSink::File(path), } => { init_subscriber(filter, open_buffered_appender(path)?); } InternalLogSink::Server { - log: ServerLogSink::Stdout, + log: LogSink::Stdout, } => { init_subscriber(filter, std::io::stdout); } InternalLogSink::Worker { - server_log: ServerLogSink::File(server_log_path), + server_log: LogSink::File(server_log_path), per_run_log_path, } => { init_worker_subscriber( @@ -86,7 +86,7 @@ pub(crate) fn init_tracing( ); } InternalLogSink::Worker { - server_log: ServerLogSink::Stdout, + server_log: LogSink::Stdout, per_run_log_path, } => { init_worker_subscriber( diff --git a/lib/crates/fabro-cli/src/main.rs b/lib/crates/fabro-cli/src/main.rs index e1e21b95c..1b843c7c2 100644 --- a/lib/crates/fabro-cli/src/main.rs +++ b/lib/crates/fabro-cli/src/main.rs @@ -481,7 +481,7 @@ async fn prepare_server_bootstrap( } else { None }; - let log = server_log_sink(log_destination, &runtime_directory); + let log = log_sink(log_destination, &runtime_directory); Ok(PreTracingBootstrap { sink: logging::InternalLogSink::Server { log }, @@ -499,7 +499,7 @@ fn prepare_run_worker_bootstrap( let log_destination = logging::resolve_log_destination( local_config.config_log_destination().unwrap_or_default(), )?; - let server_log = server_log_sink(log_destination, &runtime_directory); + let server_log = log_sink(log_destination, &runtime_directory); Ok(PreTracingBootstrap { sink: logging::InternalLogSink::Worker { @@ -511,13 +511,13 @@ fn prepare_run_worker_bootstrap( }) } -fn server_log_sink( +fn log_sink( destination: LogDestination, runtime_directory: &fabro_config::RuntimeDirectory, -) -> logging::ServerLogSink { +) -> logging::LogSink { match destination { - LogDestination::File => logging::ServerLogSink::File(runtime_directory.log_path()), - LogDestination::Stdout => logging::ServerLogSink::Stdout, + LogDestination::File => logging::LogSink::File(runtime_directory.log_path()), + LogDestination::Stdout => logging::LogSink::Stdout, } } @@ -725,7 +725,7 @@ destination = "{destination}" .expect("bootstrap should resolve"); assert_eq!(bootstrap.sink, logging::InternalLogSink::Server { - log: logging::ServerLogSink::Stdout, + log: logging::LogSink::Stdout, }); assert_eq!(bootstrap.config_log_level.as_deref(), Some("warn")); assert!(bootstrap.foreground_server_log_bootstrap.is_some()); @@ -756,7 +756,7 @@ destination = "{destination}" .expect("bootstrap should resolve"); assert_eq!(bootstrap.sink, logging::InternalLogSink::Server { - log: logging::ServerLogSink::Stdout, + log: logging::LogSink::Stdout, }); assert_eq!(bootstrap.config_log_level.as_deref(), Some("warn")); assert!(bootstrap.foreground_server_log_bootstrap.is_some()); @@ -785,7 +785,7 @@ destination = "{destination}" .expect("bootstrap should resolve"); assert_eq!(bootstrap.sink, logging::InternalLogSink::Server { - log: logging::ServerLogSink::Stdout, + log: logging::LogSink::Stdout, }); assert_eq!(bootstrap.config_log_level.as_deref(), Some("warn")); assert!(bootstrap.foreground_server_log_bootstrap.is_none()); @@ -817,7 +817,7 @@ destination = "{destination}" .expect("bootstrap should resolve"); assert_eq!(bootstrap.sink, logging::InternalLogSink::Server { - log: logging::ServerLogSink::Stdout, + log: logging::LogSink::Stdout, }); }); } @@ -930,7 +930,7 @@ destination = "{destination}" .expect("bootstrap should resolve"); assert_eq!(bootstrap.sink, logging::InternalLogSink::Worker { - server_log: logging::ServerLogSink::File( + server_log: logging::LogSink::File( storage_dir.path().join("logs").join("server.log"), ), per_run_log_path: run_dir.path().join("runtime").join("server.log"), @@ -966,7 +966,7 @@ destination = "{destination}" .expect("bootstrap should resolve"); assert_eq!(bootstrap.sink, logging::InternalLogSink::Worker { - server_log: logging::ServerLogSink::Stdout, + server_log: logging::LogSink::Stdout, per_run_log_path: run_dir.path().join("runtime").join("server.log"), }); });