tweak logging

This commit is contained in:
Qyriad 2026-03-26 12:44:48 +01:00
parent 7cfb07241c
commit 111bf2b490
3 changed files with 13 additions and 7 deletions

View file

@ -410,7 +410,7 @@ impl Daemon {
}; };
debug!("got cmd: {cmd:?}"); debug!("got cmd: {cmd:?}");
let _ = rustix::io::write(fd, b""); let _ = rustix::io::write(fd, b"");
info!("dispatching command"); info!("dispatching command {cmd:?}");
self.dispatch_cmd(cmd).unwrap_or_else(|e| todo!("{e}")); self.dispatch_cmd(cmd).unwrap_or_else(|e| todo!("{e}"));
} }
@ -461,6 +461,14 @@ impl Daemon {
.arg("--impure") .arg("--impure")
.arg("-E") .arg("-E")
.arg(expr) .arg(expr)
.tap(|cmd| {
if !tracing::enabled!(Level::INFO) {
return;
}
let args: Vec<Cow<'_, str>> = cmd.get_args().map(OsStr::to_string_lossy).collect();
let separated = args.join(" ");
info!("Spawning subprocess: [{separated}]");
})
.stdout(Stdio::piped()) .stdout(Stdio::piped())
.stderr(Stdio::piped()) .stderr(Stdio::piped())
.spawn() .spawn()
@ -638,7 +646,7 @@ impl Daemon {
let either_available = event.is_readable() || event.is_writable(); let either_available = event.is_readable() || event.is_writable();
if !either_available { if !either_available {
info!( info!(
"File descriptor {} r:{}, w:{}", "Got EVENT for file descriptor '{}': r={}, w={}",
info.display(), info.display(),
event.is_readable(), event.is_readable(),
event.is_writable(), event.is_writable(),
@ -663,7 +671,7 @@ impl Daemon {
todo!("waitid() returned None? for pid {pid}"); todo!("waitid() returned None? for pid {pid}");
}); });
debug!("waitid() for pid {pid} returned status: {status:?}"); trace!("waitid() for pid {pid} returned status: {status:?}");
let is_dead = status.exited() || status.killed() || status.dumped(); let is_dead = status.exited() || status.killed() || status.dumped();
if !is_dead { if !is_dead {
todo!("Handle process {pid} events that aren't death: {status:?}"); todo!("Handle process {pid} events that aren't death: {status:?}");
@ -690,14 +698,12 @@ impl Daemon {
} }
}, },
FdKind::ChildStdout(_pid) => { FdKind::ChildStdout(_pid) => {
warn!("got stdout");
// SAFETY: oh boy. // SAFETY: oh boy.
let stdout = unsafe { BorrowedFd::borrow_raw(fd) }; let stdout = unsafe { BorrowedFd::borrow_raw(fd) };
self.proxy_stdio(&stdout) self.proxy_stdio(&stdout)
.unwrap_or_else(|e| error!("failed to proxy child stdout: {e}")); .unwrap_or_else(|e| error!("failed to proxy child stdout: {e}"));
}, },
FdKind::ChildStderr(_pid) => { FdKind::ChildStderr(_pid) => {
warn!("got stderr");
// SAFETY: oh boy. // SAFETY: oh boy.
let stderr = unsafe { BorrowedFd::borrow_raw(fd) }; let stderr = unsafe { BorrowedFd::borrow_raw(fd) };
self.proxy_stdio(&stderr) self.proxy_stdio(&stderr)

View file

@ -16,7 +16,7 @@ fn main_wrapped() -> Result<(), Box<dyn StdError + Send + Sync + 'static>> {
// Default RUST_LOG to warn if it's not specified. // Default RUST_LOG to warn if it's not specified.
if env::var_os("RUST_LOG").is_none() { if env::var_os("RUST_LOG").is_none() {
unsafe { unsafe {
env::set_var("RUST_LOG", "warn"); env::set_var("RUST_LOG", "info");
} }
} }

View file

@ -69,7 +69,7 @@ in
path = [ config.nix.package ]; path = [ config.nix.package ];
serviceConfig = { serviceConfig = {
Environment = [ Environment = [
"RUST_LOG=info,dynix=trace" "RUST_LOG=info,dynix=debug"
]; ];
ExecSearchPath = [ "/run/current-system/sw/bin" ]; ExecSearchPath = [ "/run/current-system/sw/bin" ];
SuccessExitStatus = [ "0" "2" ]; SuccessExitStatus = [ "0" "2" ];