Logging: RUST_LOG prints to stderr, and start-up logs its milestones (#234)
The logger kept warnings in memory and wrote to a file only after Help ▸ Enable Logging, and it ignored RUST_LOG. An app that never opens its window (macOS 27 on Apple Silicon, #234) therefore left no trace. Now RUST_LOG (a level, or env_logger-style `target=level` directives) also prints what it lets through to stderr, including eframe, winit and wgpu. The desktop app logs its start-up milestones: opening the window, the graphics adapter, the app created, the first frame drawn, the window being asked to close, and the window closed. Test: rust_log_filters_by_level_and_target (engine logging). Checked by running the app with RUST_LOG=info and quitting it over the control channel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
5a7119d5fa
commit
468ed0b297
@@ -92,10 +92,17 @@ fn main() -> eframe::Result {
|
||||
wgpu_options: wgpu_options(),
|
||||
..Default::default()
|
||||
};
|
||||
// Start-up milestones: with `RUST_LOG=info` they go to stderr, so a window that never
|
||||
// appears shows how far start-up got (#234).
|
||||
log::info!("effectcraft {}: opening the window", env!("CARGO_PKG_VERSION"));
|
||||
let result = eframe::run_native(
|
||||
"EffectCraft",
|
||||
options,
|
||||
Box::new(move |cc| {
|
||||
match &cc.wgpu_render_state {
|
||||
Some(rs) => log::info!("graphics: {:?}", rs.adapter.get_info()),
|
||||
None => log::info!("graphics: no wgpu device"),
|
||||
}
|
||||
// This executable owns the shared device's handlers. Install them before
|
||||
// EffectCraft's compositor pipelines are built, without changing handlers from
|
||||
// inside Gpu::new. eframe has already constructed its presentation renderer here.
|
||||
@@ -183,15 +190,18 @@ fn main() -> eframe::Result {
|
||||
let rx = control_server::start(port, cc.egui_ctx.clone());
|
||||
app = app.with_control(rx);
|
||||
}
|
||||
log::info!("app created; the window shows after its first frame");
|
||||
Ok(Box::new(Desktop {
|
||||
#[cfg(target_os = "macos")]
|
||||
menu: native_menu::NativeBar::new(&cc.egui_ctx),
|
||||
app,
|
||||
drawn: false,
|
||||
}))
|
||||
}),
|
||||
);
|
||||
if let Err(e) = &result {
|
||||
startup_failed(e);
|
||||
match &result {
|
||||
Ok(()) => log::info!("the window closed"),
|
||||
Err(e) => startup_failed(e),
|
||||
}
|
||||
result
|
||||
}
|
||||
@@ -240,6 +250,8 @@ struct Desktop {
|
||||
app: EffectcraftApp,
|
||||
#[cfg(target_os = "macos")]
|
||||
menu: native_menu::NativeBar,
|
||||
/// The first frame was drawn (logged once).
|
||||
drawn: bool,
|
||||
}
|
||||
|
||||
impl eframe::App for Desktop {
|
||||
@@ -251,6 +263,10 @@ impl eframe::App for Desktop {
|
||||
|
||||
fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame) {
|
||||
self.app.ui(ui, frame);
|
||||
if !self.drawn {
|
||||
self.drawn = true;
|
||||
log::info!("first frame drawn");
|
||||
}
|
||||
}
|
||||
|
||||
fn on_exit(&mut self) {
|
||||
|
||||
Reference in New Issue
Block a user