Skip to content

Commit 9dfa20c

Browse files
committed
Remove println, move to logging
1 parent 4ce582f commit 9dfa20c

File tree

4 files changed

+88
-131
lines changed

4 files changed

+88
-131
lines changed

dll/src/desktop/app.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,18 @@ impl App {
5454
}
5555

5656
pub fn run(&self, root_window: WindowCreateOptions) {
57-
println!("[TRACE] App::run() called");
5857
debug_server::log(
5958
debug_server::LogLevel::Info,
6059
debug_server::LogCategory::EventLoop,
6160
"Starting App::run",
6261
None,
6362
);
64-
println!("[TRACE] App::run() - after debug_server::log");
6563
let data = self.ptr.data.clone();
66-
println!("[TRACE] App::run() - cloned data");
67-
println!("[TRACE] App::run() - cloned data");
6864
let config = self.ptr.config.clone();
69-
println!("[TRACE] App::run() - cloned config");
7065
let fc_cache = (*self.ptr.fc_cache).clone();
71-
println!("[TRACE] App::run() - cloned fc_cache");
7266

7367
// Use shell2 for the actual run loop
74-
println!("[TRACE] App::run() - calling shell2::run");
7568
let err = crate::desktop::shell2::run(data, config, fc_cache, root_window);
76-
println!("[TRACE] App::run() - returned from shell2::run");
7769

7870
if let Err(e) = err {
7971
crate::desktop::dialogs::msg_box(&format!("Error: {:?}", e));

dll/src/desktop/shell2/run.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ use azul_layout::window_state::WindowCreateOptions;
1010
use rust_fontconfig::FcFontCache;
1111

1212
use super::common::debug_server;
13-
use crate::{log_debug, log_error, log_info};
13+
use super::common::debug_server::LogCategory;
14+
use crate::{log_debug, log_error, log_info, log_trace};
1415

1516
#[cfg(target_os = "macos")]
1617
use super::macos::MacOSWindow;
@@ -274,52 +275,52 @@ pub fn run(
274275
fc_cache: Arc<FcFontCache>,
275276
root_window: WindowCreateOptions,
276277
) -> Result<(), WindowError> {
277-
println!("[TRACE] shell2::run (Windows) called");
278+
log_trace!(LogCategory::Window, "[shell2::run] Windows run() called");
278279
use std::cell::RefCell;
279280

280281
use azul_core::resources::AppTerminationBehavior;
281282

282283
use super::windows::{dlopen::MSG, registry, Win32Window};
283284

284-
println!("[TRACE] shell2::run - imports done");
285+
log_trace!(LogCategory::Window, "[shell2::run] imports done");
285286
// Wrap app_data in Arc<RefCell<>> for shared access
286-
println!("[TRACE] shell2::run - wrapping app_data in Arc<RefCell<>>");
287+
log_trace!(LogCategory::Window, "[shell2::run] wrapping app_data in Arc<RefCell<>>");
287288
let app_data_arc = Arc::new(RefCell::new(app_data));
288-
println!("[TRACE] shell2::run - app_data wrapped");
289+
log_trace!(LogCategory::Window, "[shell2::run] app_data wrapped");
289290

290291
// Create the root window
291-
println!("[TRACE] shell2::run - calling Win32Window::new");
292+
log_trace!(LogCategory::Window, "[shell2::run] calling Win32Window::new");
292293
let window = Win32Window::new(root_window, fc_cache.clone(), app_data_arc.clone())?;
293-
println!("[TRACE] shell2::run - Win32Window::new returned successfully");
294+
log_trace!(LogCategory::Window, "[shell2::run] Win32Window::new returned successfully");
294295

295296
// Store the window pointer in the user data field for the window procedure
296297
// and register in global registry for multi-window support
297298
// SAFETY: We are boxing the window and then leaking it. This is necessary
298299
// so that the pointer remains valid for the lifetime of the window.
299-
println!("[TRACE] shell2::run - boxing window");
300+
log_trace!(LogCategory::Window, "[shell2::run] boxing window");
300301
let window_ptr = Box::into_raw(Box::new(window));
301-
println!("[TRACE] shell2::run - getting hwnd");
302+
log_trace!(LogCategory::Window, "[shell2::run] getting hwnd");
302303
let hwnd = unsafe { (*window_ptr).hwnd };
303-
println!("[TRACE] shell2::run - got hwnd: {:?}", hwnd);
304+
log_trace!(LogCategory::Window, "[shell2::run] got hwnd: {:?}", hwnd);
304305

305306
unsafe {
306307
use super::windows::dlopen::constants::GWLP_USERDATA;
307-
println!("[TRACE] shell2::run - calling SetWindowLongPtrW");
308+
log_trace!(LogCategory::Window, "[shell2::run] calling SetWindowLongPtrW");
308309
((*window_ptr).win32.user32.SetWindowLongPtrW)(hwnd, GWLP_USERDATA, window_ptr as isize);
309-
println!("[TRACE] shell2::run - SetWindowLongPtrW done");
310+
log_trace!(LogCategory::Window, "[shell2::run] SetWindowLongPtrW done");
310311

311312
// Register in global window registry
312-
println!("[TRACE] shell2::run - registering window in global registry");
313+
log_trace!(LogCategory::Window, "[shell2::run] registering window in global registry");
313314
registry::register_window(hwnd, window_ptr);
314-
println!("[TRACE] shell2::run - window registered");
315+
log_trace!(LogCategory::Window, "[shell2::run] window registered");
315316

316317
// NOTE: Window is NOT shown here! It will be shown automatically by
317318
// render_and_present() after the first SwapBuffers completes.
318319
// This ensures the window appears with content, not a black/white flash.
319-
println!("[TRACE] shell2::run - window will be shown after first frame renders");
320+
log_trace!(LogCategory::Window, "[shell2::run] window will be shown after first frame renders");
320321
}
321322

322-
println!("[TRACE] shell2::run - entering main event loop");
323+
log_trace!(LogCategory::Window, "[shell2::run] entering main event loop");
323324
// Main event loop with multi-window support and V2 state diffing
324325
// Uses WaitMessage() to block efficiently when idle (no busy-waiting)
325326
// Architecture:

dll/src/desktop/shell2/windows/mod.rs

Lines changed: 17 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -193,33 +193,33 @@ impl Win32Window {
193193
macro_rules! timing_log {
194194
($step:expr) => {{
195195
let elapsed = step_start.elapsed();
196-
println!("[TIMING] {} took {:?}", $step, elapsed);
196+
log_debug!(LogCategory::Window, "[Win32] {} took {:?}", $step, elapsed);
197197
step_start = std::time::Instant::now();
198198
}};
199199
}
200200

201-
println!("[TRACE] Win32Window::new() called");
201+
log_trace!(LogCategory::Window, "[Win32] Win32Window::new() called");
202202
// Load Win32 libraries
203203
let win32 = dlopen::Win32Libraries::load().map_err(|e| {
204-
eprintln!("[ERROR] Failed to load Win32 libraries: {}", e);
204+
log_error!(LogCategory::Platform, "[Win32] Failed to load Win32 libraries: {}", e);
205205
WindowError::PlatformError(format!("Failed to load Win32 libraries: {}", e))
206206
})?;
207207
timing_log!("Load Win32 libraries");
208208

209209
// Get HINSTANCE from GetModuleHandleW(NULL)
210-
println!("[TRACE] Win32Window::new() - getting HINSTANCE");
210+
log_trace!(LogCategory::Window, "[Win32] getting HINSTANCE");
211211
let hinstance = if let Some(ref k32) = win32.kernel32 {
212212
unsafe { (k32.GetModuleHandleW)(ptr::null()) }
213213
} else {
214-
eprintln!("[ERROR] kernel32.dll not available");
214+
log_error!(LogCategory::Platform, "[Win32] kernel32.dll not available");
215215
return Err(WindowError::PlatformError(
216216
"kernel32.dll not available".into(),
217217
));
218218
};
219219
timing_log!("Get HINSTANCE");
220220

221221
if hinstance.is_null() {
222-
eprintln!("[ERROR] Failed to get HINSTANCE");
222+
log_error!(LogCategory::Platform, "[Win32] Failed to get HINSTANCE");
223223
return Err(WindowError::PlatformError("Failed to get HINSTANCE".into()));
224224
}
225225

@@ -276,7 +276,7 @@ impl Win32Window {
276276
gl_context = Some(hglrc);
277277
let hdc = unsafe { (win32.user32.GetDC)(hwnd) };
278278
if !hdc.is_null() {
279-
println!("[TRACE] Win32Window::new() - activating GL context for WebRender init");
279+
log_trace!(LogCategory::Rendering, "[Win32] activating GL context for WebRender init");
280280
#[cfg(target_os = "windows")]
281281
unsafe {
282282
use winapi::um::wingdi::wglMakeCurrent;
@@ -299,7 +299,7 @@ impl Win32Window {
299299
}
300300
Err(e) => {
301301
// Fall back to software rendering
302-
eprintln!("[WARN] GL context creation failed: {:?}, falling back to software", e);
302+
log_warn!(LogCategory::Rendering, "[Win32] GL context creation failed: {:?}, falling back to software", e);
303303
gl_context_ptr = OptionGlContextPtr::None;
304304
}
305305
}
@@ -416,7 +416,7 @@ impl Win32Window {
416416
// We'll show the window AFTER a11y is set up.
417417
let should_show_window = layout_window.current_window_state.flags.is_visible;
418418
let window_frame = layout_window.current_window_state.flags.frame;
419-
println!("[TRACE] Win32Window::new() - deferring show_window until after a11y init (is_visible: {})", should_show_window);
419+
log_trace!(LogCategory::Window, "[Win32] deferring show_window until after a11y init (is_visible: {})", should_show_window);
420420

421421
// Position window on requested monitor (or center on primary)
422422
// This can be done before showing
@@ -488,7 +488,7 @@ impl Win32Window {
488488
{
489489
if let Err(e) = result.accessibility_adapter.initialize(hwnd) {
490490
// Don't fail window creation if a11y fails, just log and continue
491-
eprintln!("[WARN] a11y adapter init failed: {}, continuing without a11y", e);
491+
log_warn!(LogCategory::Platform, "[Win32] a11y adapter init failed: {}, continuing without a11y", e);
492492
}
493493
}
494494
timing_log!("Initialize accessibility adapter");
@@ -572,7 +572,7 @@ impl Win32Window {
572572
}
573573
timing_log!("Final setup (callback + debug timer)");
574574

575-
println!("[TIMING] ===== TOTAL Win32Window::new() took {:?} =====", total_start.elapsed());
575+
log_debug!(LogCategory::Window, "[Win32] ===== TOTAL Win32Window::new() took {:?} =====", total_start.elapsed());
576576
Ok(result)
577577
}
578578

@@ -687,19 +687,19 @@ impl Win32Window {
687687
if !self.first_frame_shown {
688688
// Check if user wants the window visible
689689
if self.current_window_state.flags.is_visible {
690-
println!("[TRACE] First frame rendered + SwapBuffers done - showing window NOW");
690+
log_trace!(LogCategory::Rendering, "[Win32] First frame rendered + SwapBuffers done - showing window NOW");
691691

692692
// Force DWM to latch the new frame buffer before making the window visible.
693693
// This prevents the "Black Frame" flash by blocking until DWM composition is done.
694694
if let Some(ref dwmapi) = self.win32.dwmapi_funcs {
695695
(dwmapi.DwmFlush)();
696-
println!("[TRACE] DwmFlush completed");
696+
log_trace!(LogCategory::Rendering, "[Win32] DwmFlush completed");
697697
}
698698

699699
use dlopen::constants::SW_SHOW;
700700
(self.win32.user32.ShowWindow)(self.hwnd, SW_SHOW);
701701
(self.win32.user32.UpdateWindow)(self.hwnd);
702-
println!("[TRACE] Window shown after first real frame");
702+
log_trace!(LogCategory::Rendering, "[Win32] Window shown after first real frame");
703703
}
704704
self.first_frame_shown = true;
705705
}
@@ -1496,57 +1496,23 @@ unsafe extern "system" fn window_proc(
14961496
let window = &mut *window_ptr;
14971497
// Now we can use window.win32 instead of temp_win32 for the rest of the function
14981498

1499-
// Debug: Log all WM messages
1500-
let msg_name = match msg {
1501-
0x0001 => "WM_CREATE",
1502-
0x0002 => "WM_DESTROY",
1503-
0x0005 => "WM_SIZE",
1504-
0x0007 => "WM_SETFOCUS",
1505-
0x0008 => "WM_KILLFOCUS",
1506-
0x000F => "WM_PAINT",
1507-
0x0010 => "WM_CLOSE",
1508-
0x0014 => "WM_ERASEBKGND",
1509-
0x0100 => "WM_KEYDOWN",
1510-
0x0101 => "WM_KEYUP",
1511-
0x0102 => "WM_CHAR",
1512-
0x0104 => "WM_SYSKEYDOWN",
1513-
0x0105 => "WM_SYSKEYUP",
1514-
0x0106 => "WM_SYSCHAR",
1515-
0x0111 => "WM_COMMAND",
1516-
0x0113 => "WM_TIMER",
1517-
0x0200 => "WM_MOUSEMOVE",
1518-
0x0201 => "WM_LBUTTONDOWN",
1519-
0x0202 => "WM_LBUTTONUP",
1520-
0x0204 => "WM_RBUTTONDOWN",
1521-
0x0205 => "WM_RBUTTONUP",
1522-
0x0207 => "WM_MBUTTONDOWN",
1523-
0x0208 => "WM_MBUTTONUP",
1524-
0x020A => "WM_MOUSEWHEEL",
1525-
0x0233 => "WM_DROPFILES",
1526-
0x02A3 => "WM_MOUSELEAVE",
1527-
0x02E0 => "WM_DPICHANGED",
1528-
_ => "OTHER",
1529-
};
1530-
println!("[WM] msg=0x{:04X} ({}) wparam={} lparam={}", msg, msg_name, wparam, lparam);
1531-
15321499
// Handle messages
15331500
match msg {
15341501
WM_CREATE => {
1535-
println!("[WM_CREATE] Window created");
1536-
// Window created
1502+
log_debug!(LogCategory::Window, "[Win32] WM_CREATE - Window created");
15371503
0
15381504
}
15391505

15401506
WM_DESTROY => {
1541-
println!("[WM_DESTROY] Window destroyed");
1507+
log_debug!(LogCategory::Window, "[Win32] WM_DESTROY - Window destroyed");
15421508
// Window destroyed - unregister from global registry
15431509
window.is_open = false;
15441510
registry::unregister_window(hwnd);
15451511
0
15461512
}
15471513

15481514
WM_CLOSE => {
1549-
println!("[WM_CLOSE] Close requested");
1515+
log_debug!(LogCategory::Window, "[Win32] WM_CLOSE - Close requested");
15501516
// User clicked close button - set close_requested flag
15511517
// and process callbacks to allow cancellation
15521518
window.current_window_state.flags.close_requested = true;

0 commit comments

Comments
 (0)