mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-08-28 05:27:41 +00:00
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) <noreply@anthropic.com>
This commit is contained in:
parent
7abc11adc9
commit
e6ca9eba87
2 changed files with 19 additions and 19 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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"),
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue