mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
fix(gui-client): don't drop bootstrap logger early (#9763)
The GUI client binary performs quite a few checks prior to setting up logging. In order to log at least something, we have a bootstrap logger config that logs to stdout based on the `RUST_LOG` env var. However, in the context of an error, the logger guard was dropped to early and therefore we couldn't actually see the error. To fix this, we pass a mutable `Option` in to `try_main` instead. This allows the function to drop the bootstrap logger once the real one is set up but also keep logging using the bootstrap logger in case of an error.
This commit is contained in:
@@ -18,8 +18,8 @@ use tracing::subscriber::DefaultGuard;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let bootstrap_log_guard =
|
||||
firezone_logging::setup_bootstrap().expect("Failed to setup bootstrap logger");
|
||||
let mut bootstrap_log_guard =
|
||||
Some(firezone_logging::setup_bootstrap().expect("Failed to setup bootstrap logger"));
|
||||
|
||||
// Mitigates a bug in Ubuntu 22.04 - Under Wayland, some features of the window decorations like minimizing, closing the windows, etc., doesn't work unless you double-click the titlebar first.
|
||||
// SAFETY: No other thread is running yet
|
||||
@@ -30,7 +30,7 @@ fn main() -> ExitCode {
|
||||
let mut telemetry = Telemetry::default();
|
||||
let rt = tokio::runtime::Runtime::new().expect("failed to build runtime");
|
||||
|
||||
match try_main(&rt, bootstrap_log_guard, &mut telemetry) {
|
||||
match try_main(&rt, &mut bootstrap_log_guard, &mut telemetry) {
|
||||
Ok(()) => {
|
||||
rt.block_on(telemetry.stop());
|
||||
|
||||
@@ -48,7 +48,7 @@ fn main() -> ExitCode {
|
||||
|
||||
fn try_main(
|
||||
rt: &Runtime,
|
||||
bootstrap_log_guard: DefaultGuard,
|
||||
bootstrap_log_guard: &mut Option<DefaultGuard>,
|
||||
telemetry: &mut Telemetry,
|
||||
) -> Result<()> {
|
||||
let cli = Cli::parse();
|
||||
@@ -105,7 +105,7 @@ fn try_main(
|
||||
.or(mdm_settings.log_filter.clone())
|
||||
.unwrap_or_else(|| advanced_settings.log_filter.clone());
|
||||
|
||||
drop(bootstrap_log_guard);
|
||||
drop(bootstrap_log_guard.take());
|
||||
|
||||
let logging::Handles {
|
||||
logger: _logger,
|
||||
|
||||
Reference in New Issue
Block a user