From 0b7d409fddc9a8414afcd7cf34273039fd73a9ee Mon Sep 17 00:00:00 2001 From: Jay Bosamiya Date: Tue, 14 Apr 2026 14:00:08 -0700 Subject: [PATCH 1/3] Set up tracing subscriber for Linux userland runner --- litebox_runner_linux_userland/Cargo.toml | 2 ++ litebox_runner_linux_userland/src/lib.rs | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/litebox_runner_linux_userland/Cargo.toml b/litebox_runner_linux_userland/Cargo.toml index 08e635477..e8d88d301 100644 --- a/litebox_runner_linux_userland/Cargo.toml +++ b/litebox_runner_linux_userland/Cargo.toml @@ -14,6 +14,8 @@ litebox_platform_multiplex = { version = "0.1.0", path = "../litebox_platform_mu litebox_shim_linux = { version = "0.1.0", path = "../litebox_shim_linux" } litebox_syscall_rewriter = { version = "0.1.0", path = "../litebox_syscall_rewriter" } memmap2 = "0.9.8" +tracing-subscriber = { version = "0.3.22", features = ["env-filter"] } +litebox_util_log = { version = "0.1.0", path = "../litebox_util_log", features = ["backend_tracing"] } [dev-dependencies] sha2 = "0.10" diff --git a/litebox_runner_linux_userland/src/lib.rs b/litebox_runner_linux_userland/src/lib.rs index f15d1f7ab..152178fb0 100644 --- a/litebox_runner_linux_userland/src/lib.rs +++ b/litebox_runner_linux_userland/src/lib.rs @@ -12,6 +12,10 @@ use std::path::{Path, PathBuf}; extern crate alloc; /// Run Linux programs with LiteBox on unmodified Linux +/// +/// Detailed logging can be controlled via the `LITEBOX_LOG` environment variable. For example: +/// - `LITEBOX_LOG=debug` to show debug and higher level logs +/// - `LITEBOX_LOG=litebox=debug,litebox::fs=trace` for multiple filters at different levels #[derive(Parser, Debug)] #[allow(clippy::struct_excessive_bools)] pub struct CliArgs { @@ -124,6 +128,16 @@ fn mmapped_file(path: impl AsRef) -> Result { /// panic. If it does actually panic, then ping the authors of LiteBox, and likely a better error /// message could be thrown instead. pub fn run(cli_args: CliArgs) -> Result<()> { + tracing_subscriber::fmt() + .with_timer(tracing_subscriber::fmt::time::uptime()) + .with_level(true) + .with_env_filter( + tracing_subscriber::EnvFilter::builder() + .with_env_var("LITEBOX_LOG") + .from_env_lossy(), + ) + .init(); + if !cli_args.insert_files.is_empty() { unimplemented!( "this should (hopefully soon) have a nicer interface to support loading in files" From 35dd59567019ea07cefb53ff707c183c79cd9f30 Mon Sep 17 00:00:00 2001 From: Jay Bosamiya Date: Tue, 14 Apr 2026 14:00:08 -0700 Subject: [PATCH 2/3] Enable litebox_util_log for core litebox crate --- litebox/Cargo.toml | 1 + litebox/src/litebox.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/litebox/Cargo.toml b/litebox/Cargo.toml index 9a8b2e401..44c0f35c7 100644 --- a/litebox/Cargo.toml +++ b/litebox/Cargo.toml @@ -19,6 +19,7 @@ ringbuf = { version = "0.4.8", default-features = false, features = ["alloc"] } buddy_system_allocator = { version = "0.11.0", default-features = false, features = ["use_spin"] } # Depend on (currently unreleased) slabmalloc `main`, which contains some fixes on top of `0.11.0` slabmalloc = { git = "https://github.com/gz/rust-slabmalloc.git", rev = "19480b2e82704210abafe575fb9699184c1be110" } +litebox_util_log = { version = "0.1.0", path = "../litebox_util_log" } [target.'cfg(windows)'.dependencies] windows-sys = { version = "0.60.2", features = [ diff --git a/litebox/src/litebox.rs b/litebox/src/litebox.rs index f179edde3..2fb209c22 100644 --- a/litebox/src/litebox.rs +++ b/litebox/src/litebox.rs @@ -64,10 +64,14 @@ impl LiteBox { #[cfg(feature = "lock_tracing")] crate::sync::lock_tracing::LockTracker::init(platform); + let descriptors = RwLock::new(Descriptors::new_from_litebox_creation()); + + litebox_util_log::trace!("LiteBox instance initialized"); + Self { x: Arc::new(LiteBoxX { platform, - descriptors: RwLock::new(Descriptors::new_from_litebox_creation()), + descriptors, }), } } From 5c8d672b7f8ccafa33d3984f283cfff9e640595f Mon Sep 17 00:00:00 2001 From: Jay Bosamiya Date: Tue, 14 Apr 2026 14:00:08 -0700 Subject: [PATCH 3/3] snap --- Cargo.lock | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index ca5e7a9a3..920abed58 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1450,6 +1450,7 @@ dependencies = [ "buddy_system_allocator", "either", "hashbrown", + "litebox_util_log", "rangemap", "ringbuf", "slabmalloc", @@ -1623,8 +1624,10 @@ dependencies = [ "litebox_platform_multiplex", "litebox_shim_linux", "litebox_syscall_rewriter", + "litebox_util_log", "memmap2", "sha2", + "tracing-subscriber", "walkdir", ]