This commit is contained in:
Mateusz Gruszczyński committed 2026-10-09 17:09:41 +02:00
1 parent 3e33982cd3
commit ad95bfb050
27 files changed
+309 -80

No files matched your search

+29 -1
View File
@@ -273,6 +273,7 @@ fn resolve_installed_data_dir(configured: PathBuf, explicitly_configured: bool)
async fn application() -> Result<()> {
let error_log = rust_proxy::logging::ErrorLogController::start();
rust_proxy::logging::install_error_log_controller(error_log.clone())?;
let console_router = error_log.clone();
let filter = tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "rust_proxy=info,warn".into());
tracing_subscriber::registry()
@@ -280,10 +281,37 @@ async fn application() -> Result<()> {
.with(
tracing_subscriber::fmt::layer()
.with_target(false)
.with_writer(rust_proxy::logging::RedactingStderr),
.with_writer(rust_proxy::logging::RedactingStderr)
.with_filter(tracing_subscriber::filter::filter_fn(move |metadata| {
console_router.console_enabled_for(metadata.level())
})),
)
.with(rust_proxy::logging::ErrorLogLayer::new(error_log))
.init();
// Rust's default panic hook writes directly to stderr, bypassing tracing
// and the configured error file. Route worker panics through the same
// WARN/ERROR sink as other diagnostics without duplicate journald output.
std::panic::set_hook(Box::new(|info| {
let payload = if let Some(value) = info.payload().downcast_ref::<&str>() {
(*value).to_owned()
} else if let Some(value) = info.payload().downcast_ref::<String>() {
value.clone()
} else {
"non-string panic payload".to_owned()
};
let location = info.location().map_or_else(
|| "unknown".to_owned(),
|place| format!("{}:{}:{}", place.file(), place.line(), place.column()),
);
let thread = std::thread::current();
tracing::error!(
target: "rust_proxy::panic",
thread = thread.name().unwrap_or("unnamed"),
location = %location,
panic = %payload,
"RustProxy worker panicked"
);
}));
let matches = Cli::command().get_matches();
let explicit = |matches: &clap::ArgMatches, id: &str| {
matches.value_source(id).is_some_and(|source| {