Skip to content

Commit

Permalink
Fixed logger startup and added session logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
apognu committed Oct 16, 2024
1 parent 06afb4d commit 754c25f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/greeter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use tokio::{
net::UnixStream,
sync::{mpsc::Sender, RwLock, RwLockWriteGuard},
};
use tracing_appender::non_blocking::WorkerGuard;
use zeroize::Zeroize;

use crate::{
Expand Down Expand Up @@ -102,6 +103,7 @@ pub enum GreetAlign {
pub struct Greeter {
pub debug: bool,
pub logfile: String,
pub logger: Option<WorkerGuard>,

#[default(DEFAULT_LOCALE)]
pub locale: Locale,
Expand Down Expand Up @@ -227,6 +229,8 @@ impl Greeter {
greeter.connect().await;
}

greeter.logger = crate::init_logger(&greeter);

let sessions = get_sessions(&greeter).unwrap_or_default();

if let SessionSource::None = greeter.session_source {
Expand Down
6 changes: 6 additions & 0 deletions src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ pub fn get_sessions(greeter: &Greeter) -> Result<Vec<Session>, Box<dyn Error>> {
let mut files = vec![];

for (path, session_type) in paths.iter() {
tracing::info!("reading {:?} sessions from '{}'", session_type, path.display());

if let Ok(entries) = fs::read_dir(path) {
files.extend(entries.flat_map(|entry| entry.map(|entry| load_desktop_file(entry.path(), *session_type))).flatten().flatten());
}
Expand All @@ -273,9 +275,11 @@ where
let section = desktop.section(Some("Desktop Entry")).ok_or("no Desktop Entry section in desktop file")?;

if let Some("true") = section.get("Hidden") {
tracing::info!("ignoring session in '{}': Hidden=true", path.as_ref().display());
return Ok(None);
}
if let Some("true") = section.get("NoDisplay") {
tracing::info!("ignoring session in '{}': NoDisplay=true", path.as_ref().display());
return Ok(None);
}

Expand All @@ -284,6 +288,8 @@ where
let exec = section.get("Exec").ok_or("no Exec property in desktop file")?;
let xdg_desktop_names = section.get("DesktopNames").map(str::to_string);

tracing::info!("got session '{}' in '{}'", name, path.as_ref().display());

Ok(Some(Session {
slug,
name: name.to_string(),
Expand Down
2 changes: 0 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ async fn run<B>(backend: B, mut greeter: Greeter, mut events: Events) -> Result<
where
B: tui::backend::Backend,
{
let _guard = init_logger(&greeter);

tracing::info!("tuigreet started");

register_panic_handler();
Expand Down

0 comments on commit 754c25f

Please sign in to comment.