chore: cleanup logs

This commit is contained in:
Ashley Wulber 2025-09-12 17:39:37 -04:00 committed by Michael Murphy
parent da11207f12
commit 79bf2cb4f8
16 changed files with 396 additions and 169 deletions

View file

@ -50,7 +50,7 @@ impl UserData {
self.bg_path_data.insert(path.clone(), bytes);
}
Err(err) => {
log::error!("failed to read wallpaper {:?}: {:?}", path, err);
tracing::error!("failed to read wallpaper {:?}: {:?}", path, err);
}
}
}
@ -80,7 +80,7 @@ impl UserData {
self.icon_opt = Some(icon_data);
}
Err(err) => {
log::error!("failed to read icon {:?}: {:?}", icon_path, err);
tracing::error!("failed to read icon {:?}: {:?}", icon_path, err);
}
}
}
@ -92,12 +92,12 @@ impl UserData {
is_dark = theme_mode.is_dark;
}
Err((errs, theme_mode)) => {
log::error!("failed to load cosmic-theme config: {:?}", errs);
tracing::error!("failed to load cosmic-theme config: {:?}", errs);
is_dark = theme_mode.is_dark;
}
},
Err(err) => {
log::error!("failed to create cosmic-theme mode helper: {:?}", err);
tracing::error!("failed to create cosmic-theme mode helper: {:?}", err);
}
}
@ -111,12 +111,12 @@ impl UserData {
self.theme_opt = Some(theme);
}
Err((errs, theme)) => {
log::error!("failed to load cosmic-theme config: {:?}", errs);
tracing::error!("failed to load cosmic-theme config: {:?}", errs);
self.theme_opt = Some(theme);
}
},
Err(err) => {
log::error!("failed to create cosmic-theme config helper: {:?}", err);
tracing::error!("failed to create cosmic-theme config helper: {:?}", err);
}
}
@ -130,12 +130,12 @@ impl UserData {
self.theme_builder_opt = Some(theme);
}
Err((errs, theme)) => {
log::error!("failed to load cosmic-theme builder config: {:?}", errs);
tracing::error!("failed to load cosmic-theme builder config: {:?}", errs);
self.theme_builder_opt = Some(theme);
}
},
Err(err) => {
log::error!(
tracing::error!(
"failed to create cosmic-theme builder config helper: {:?}",
err
);
@ -149,12 +149,12 @@ impl UserData {
self.bg_state = state;
}
Err((errs, state)) => {
log::error!("failed to load cosmic-bg state: {:?}", errs);
tracing::error!("failed to load cosmic-bg state: {:?}", errs);
self.bg_state = state;
}
},
Err(err) => {
log::error!("failed to create cosmic-bg state helper: {:?}", err);
tracing::error!("failed to create cosmic-bg state helper: {:?}", err);
}
}
self.load_wallpapers_as_user();
@ -167,14 +167,14 @@ impl UserData {
self.accessibility_zoom = config.accessibility_zoom;
}
Err((errs, config)) => {
log::error!("errors loading cosmic-comp config: {:?}", errs);
tracing::error!("errors loading cosmic-comp config: {:?}", errs);
self.xkb_config_opt = Some(config.xkb_config);
self.accessibility_zoom = config.accessibility_zoom;
}
};
}
Err(err) => {
log::error!("failed to create cosmic-comp config handler: {}", err);
tracing::error!("failed to create cosmic-comp config handler: {}", err);
}
};
@ -198,12 +198,12 @@ impl UserData {
self.time_applet_config = config;
}
Err((errs, config)) => {
log::error!("failed to load time applet config: {:?}", errs);
tracing::error!("failed to load time applet config: {:?}", errs);
self.time_applet_config = config;
}
},
Err(err) => {
log::error!(
tracing::error!(
"failed to create CosmicAppletTime config handler: {:?}",
err
);

View file

@ -1,5 +1,10 @@
use color_eyre::eyre::Context;
use color_eyre::eyre::WrapErr;
use cosmic_greeter_daemon::UserData;
use std::{env, error::Error, future::pending, io, path::Path};
use tracing::metadata::LevelFilter;
use tracing::{error, warn};
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
use zbus::{connection::Builder, DBusError};
//IMPORTANT: this function is critical to the security of this proxy. It must ensure that the
@ -99,7 +104,35 @@ impl GreeterProxy {
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init();
color_eyre::install().wrap_err("failed to install color_eyre error handler")?;
let trace = tracing_subscriber::registry();
let env_filter = EnvFilter::builder()
.with_default_directive(LevelFilter::WARN.into())
.from_env_lossy();
#[cfg(feature = "systemd")]
if let Ok(journald) = tracing_journald::layer() {
trace
.with(journald)
.with(env_filter)
.try_init()
.wrap_err("failed to initialize logger")?;
} else {
trace
.with(fmt::layer())
.with(env_filter)
.try_init()
.wrap_err("failed to initialize logger")?;
warn!("failed to connect to journald")
}
#[cfg(not(feature = "systemd"))]
trace
.with(fmt::layer())
.with(env_filter)
.try_init()
.wrap_err("failed to initialize logger")?;
let _conn = Builder::system()?
.name("com.system76.CosmicGreeter")?