feat: switch to systemd-journal-logger, add debug logging (v0.4.0)
Replace env_logger file-based logging with systemd-journal-logger for consistency with moonlock and native journalctl integration. Add debug-level logging at all decision points: config loading, user/session detection, avatar resolution, locale detection, IPC messages, login flow, and persistence. No credentials are ever logged.
This commit is contained in:
+29
-1
@@ -163,6 +163,10 @@ pub fn create_greeter_window(
|
||||
let strings = load_strings(None);
|
||||
let all_users = users::get_users(None);
|
||||
let all_sessions = sessions::get_sessions(None, None);
|
||||
log::debug!("Greeter window: {} user(s), {} session(s)", all_users.len(), all_sessions.len());
|
||||
if let Some(ref theme) = config.gtk_theme {
|
||||
log::debug!("GTK theme: {theme}");
|
||||
}
|
||||
|
||||
let state = Rc::new(RefCell::new(GreeterState {
|
||||
selected_user: None,
|
||||
@@ -489,6 +493,7 @@ fn select_initial_user(
|
||||
.as_ref()
|
||||
.and_then(|name| users.iter().find(|u| &u.username == name))
|
||||
.unwrap_or(&users[0]);
|
||||
log::debug!("Initial user: {} (last_user={:?})", target.username, last_username);
|
||||
|
||||
switch_to_user(
|
||||
target,
|
||||
@@ -515,6 +520,7 @@ fn switch_to_user(
|
||||
sessions: &[Session],
|
||||
window: >k::ApplicationWindow,
|
||||
) {
|
||||
log::debug!("Switching to user: {}", user.username);
|
||||
{
|
||||
let mut s = state.borrow_mut();
|
||||
s.selected_user = Some(user.clone());
|
||||
@@ -531,8 +537,10 @@ fn switch_to_user(
|
||||
};
|
||||
|
||||
if let Some(texture) = cached {
|
||||
log::debug!("Avatar cache hit for {}", user.username);
|
||||
avatar_image.set_paintable(Some(&texture));
|
||||
} else {
|
||||
log::debug!("Avatar cache miss for {}", user.username);
|
||||
let avatar_path = users::get_avatar_path(&user.username, &user.home);
|
||||
if let Some(path) = avatar_path {
|
||||
// get_avatar_path already checks existence — go straight to loading
|
||||
@@ -558,6 +566,7 @@ fn set_avatar_from_file(
|
||||
// Reject oversized files
|
||||
if let Ok(meta) = std::fs::metadata(path) {
|
||||
if meta.len() > MAX_AVATAR_FILE_SIZE {
|
||||
log::debug!("Avatar file too large ({} bytes): {}", meta.len(), path.display());
|
||||
image.set_icon_name(Some("avatar-default-symbolic"));
|
||||
return;
|
||||
}
|
||||
@@ -574,7 +583,8 @@ fn set_avatar_from_file(
|
||||
}
|
||||
image.set_paintable(Some(&texture));
|
||||
}
|
||||
Err(_) => {
|
||||
Err(e) => {
|
||||
log::debug!("Failed to load avatar {}: {e}", path.display());
|
||||
image.set_icon_name(Some("avatar-default-symbolic"));
|
||||
}
|
||||
}
|
||||
@@ -590,10 +600,12 @@ fn set_default_avatar(
|
||||
{
|
||||
let s = state.borrow();
|
||||
if let Some(ref texture) = s.default_avatar_texture {
|
||||
log::debug!("Default avatar: using cached texture");
|
||||
image.set_paintable(Some(texture));
|
||||
return;
|
||||
}
|
||||
}
|
||||
log::debug!("Default avatar: tinting SVG from GResource");
|
||||
|
||||
let resource_path = users::get_default_avatar_path();
|
||||
if let Ok(bytes) =
|
||||
@@ -698,6 +710,7 @@ fn show_greetd_error(
|
||||
|
||||
/// Cancel any in-progress greetd session.
|
||||
fn cancel_pending_session(state: &Rc<RefCell<GreeterState>>) {
|
||||
log::debug!("Cancelling pending greetd session");
|
||||
let s = state.borrow();
|
||||
s.login_cancelled
|
||||
.store(true, std::sync::atomic::Ordering::SeqCst);
|
||||
@@ -731,6 +744,7 @@ fn attempt_login(
|
||||
password_entry: >k::PasswordEntry,
|
||||
session_dropdown: >k::DropDown,
|
||||
) {
|
||||
log::debug!("Login attempt for user: {}", user.username);
|
||||
let sock_path = match std::env::var("GREETD_SOCK") {
|
||||
Ok(p) if !p.is_empty() => p,
|
||||
_ => {
|
||||
@@ -740,6 +754,7 @@ fn attempt_login(
|
||||
};
|
||||
|
||||
// Validate socket path
|
||||
log::debug!("GREETD_SOCK: {sock_path}");
|
||||
let sock_pathbuf = PathBuf::from(&sock_path);
|
||||
if !sock_pathbuf.is_absolute() {
|
||||
show_error(
|
||||
@@ -886,9 +901,11 @@ fn login_worker(
|
||||
strings: &Strings,
|
||||
) -> Result<LoginResult, String> {
|
||||
if login_cancelled.load(std::sync::atomic::Ordering::SeqCst) {
|
||||
log::debug!("Login cancelled before connect");
|
||||
return Ok(LoginResult::Cancelled);
|
||||
}
|
||||
|
||||
log::debug!("Connecting to greetd socket: {sock_path}");
|
||||
let mut sock = UnixStream::connect(sock_path).map_err(|e| e.to_string())?;
|
||||
if let Err(e) = sock.set_read_timeout(Some(std::time::Duration::from_secs(10))) {
|
||||
log::warn!("Failed to set read timeout: {e}");
|
||||
@@ -902,6 +919,7 @@ fn login_worker(
|
||||
}
|
||||
|
||||
// Step 1: Create session — if a stale session exists, cancel it and retry
|
||||
log::debug!("Creating greetd session for {username}");
|
||||
let mut response = ipc::create_session(&mut sock, username).map_err(|e| e.to_string())?;
|
||||
|
||||
if login_cancelled.load(std::sync::atomic::Ordering::SeqCst) {
|
||||
@@ -909,6 +927,7 @@ fn login_worker(
|
||||
}
|
||||
|
||||
if response.get("type").and_then(|v| v.as_str()) == Some("error") {
|
||||
log::debug!("Stale session detected, cancelling and retrying");
|
||||
let _ = ipc::cancel_session(&mut sock);
|
||||
response = ipc::create_session(&mut sock, username).map_err(|e| e.to_string())?;
|
||||
if login_cancelled.load(std::sync::atomic::Ordering::SeqCst) {
|
||||
@@ -927,6 +946,7 @@ fn login_worker(
|
||||
|
||||
// Step 2: Send password if auth message received
|
||||
if response.get("type").and_then(|v| v.as_str()) == Some("auth_message") {
|
||||
log::debug!("Sending auth response for {username}");
|
||||
response =
|
||||
ipc::post_auth_response(&mut sock, Some(password)).map_err(|e| e.to_string())?;
|
||||
|
||||
@@ -953,6 +973,7 @@ fn login_worker(
|
||||
|
||||
// Step 3: Start session
|
||||
if response.get("type").and_then(|v| v.as_str()) == Some("success") {
|
||||
log::debug!("Auth successful, starting session: {exec_cmd}");
|
||||
let cmd = match split_shell_words(exec_cmd) {
|
||||
Some(words) if !words.is_empty() => words,
|
||||
_ => {
|
||||
@@ -981,6 +1002,7 @@ fn login_worker(
|
||||
}
|
||||
|
||||
if response.get("type").and_then(|v| v.as_str()) == Some("success") {
|
||||
log::info!("Login successful for {username}");
|
||||
return Ok(LoginResult::Success {
|
||||
username: username.to_string(),
|
||||
});
|
||||
@@ -1039,8 +1061,10 @@ fn load_last_user_from(path: &Path) -> Option<String> {
|
||||
let content = std::fs::read_to_string(path).ok()?;
|
||||
let username = content.trim();
|
||||
if is_valid_username(username) {
|
||||
log::debug!("Loaded last user: {username}");
|
||||
Some(username.to_string())
|
||||
} else {
|
||||
log::debug!("Invalid last user in {}", path.display());
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -1050,6 +1074,7 @@ fn save_last_user(username: &str) {
|
||||
}
|
||||
|
||||
fn save_last_user_to(path: &Path, username: &str) {
|
||||
log::debug!("Saving last user: {username}");
|
||||
if let Some(parent) = path.parent() {
|
||||
let _ = std::fs::create_dir_all(parent);
|
||||
}
|
||||
@@ -1072,8 +1097,10 @@ fn load_last_session_from(path: &Path) -> Option<String> {
|
||||
let content = std::fs::read_to_string(path).ok()?;
|
||||
let name = content.trim();
|
||||
if is_valid_session_name(name) {
|
||||
log::debug!("Loaded last session: {name}");
|
||||
Some(name.to_string())
|
||||
} else {
|
||||
log::debug!("Invalid last session in {}", path.display());
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -1101,6 +1128,7 @@ fn save_last_session(username: &str, session_name: &str) {
|
||||
}
|
||||
|
||||
fn save_last_session_to(path: &Path, session_name: &str) {
|
||||
log::debug!("Saving last session: {session_name}");
|
||||
use std::os::unix::fs::OpenOptionsExt;
|
||||
use std::io::Write;
|
||||
let _ = std::fs::OpenOptions::new()
|
||||
|
||||
Reference in New Issue
Block a user