refactor: replace Console.WriteLine with DiagnosticLog service
All checks were successful
CI / Build (Linux) (push) Successful in 21s
All checks were successful
CI / Build (Linux) (push) Successful in 21s
Replace 495+ Console.WriteLine debug statements across handlers, dispatching, services, views, and window components with centralized DiagnosticLog service for proper logging infrastructure. Add new DiagnosticLog.cs service with Debug/Error methods to eliminate debug logging pollution in production code.
This commit is contained in:
@@ -3,6 +3,7 @@ using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Maui.Platform.Linux.Native;
|
||||
using Microsoft.Maui.Platform.Linux.Rendering;
|
||||
using Microsoft.Maui.Platform.Linux.Services;
|
||||
|
||||
namespace Microsoft.Maui.Platform.Linux.Window;
|
||||
|
||||
@@ -163,7 +164,7 @@ public sealed class GtkHostWindow : IDisposable
|
||||
ConnectSignal(_window, "button-release-event", Marshal.GetFunctionPointerForDelegate(_buttonReleaseHandler));
|
||||
ConnectSignal(_window, "motion-notify-event", Marshal.GetFunctionPointerForDelegate(_motionHandler));
|
||||
|
||||
Console.WriteLine($"[GtkHostWindow] Created GTK window on X11: {width}x{height}");
|
||||
DiagnosticLog.Debug("GtkHostWindow", $"Created GTK window on X11: {width}x{height}");
|
||||
}
|
||||
|
||||
private void ConnectSignal(IntPtr widget, string signal, IntPtr handler)
|
||||
@@ -202,7 +203,7 @@ public sealed class GtkHostWindow : IDisposable
|
||||
1 => "Left",
|
||||
_ => $"Other({button})",
|
||||
};
|
||||
Console.WriteLine($"[GtkHostWindow] ButtonPress at ({x:F1}, {y:F1}), button={button} ({buttonName})");
|
||||
DiagnosticLog.Debug("GtkHostWindow", $"ButtonPress at ({x:F1}, {y:F1}), button={button} ({buttonName})");
|
||||
PointerPressed?.Invoke(this, (x, y, button));
|
||||
_skiaSurface?.RaisePointerPressed(x, y, button);
|
||||
return false;
|
||||
@@ -256,7 +257,7 @@ public sealed class GtkHostWindow : IDisposable
|
||||
{
|
||||
if (string.IsNullOrEmpty(iconPath) || !File.Exists(iconPath))
|
||||
{
|
||||
Console.WriteLine("[GtkHostWindow] Icon file not found: " + iconPath);
|
||||
DiagnosticLog.Warn("GtkHostWindow", "Icon file not found: " + iconPath);
|
||||
return;
|
||||
}
|
||||
try
|
||||
@@ -266,12 +267,12 @@ public sealed class GtkHostWindow : IDisposable
|
||||
{
|
||||
GtkNative.gtk_window_set_icon(_window, pixbuf);
|
||||
GtkNative.g_object_unref(pixbuf);
|
||||
Console.WriteLine("[GtkHostWindow] Set window icon: " + iconPath);
|
||||
DiagnosticLog.Debug("GtkHostWindow", "Set window icon: " + iconPath);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("[GtkHostWindow] Failed to set icon: " + ex.Message);
|
||||
DiagnosticLog.Error("GtkHostWindow", "Failed to set icon", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +286,7 @@ public sealed class GtkHostWindow : IDisposable
|
||||
GtkNative.gtk_widget_set_size_request(webViewWidget, width, height);
|
||||
GtkNative.gtk_fixed_put(_webViewLayer, webViewWidget, x, y);
|
||||
GtkNative.gtk_widget_show(webViewWidget);
|
||||
Console.WriteLine($"[GtkHostWindow] Added WebView at ({x}, {y}) size {width}x{height}");
|
||||
DiagnosticLog.Debug("GtkHostWindow", $"Added WebView at ({x}, {y}) size {width}x{height}");
|
||||
}
|
||||
|
||||
public void MoveResizeWebView(IntPtr webViewWidget, int x, int y, int width, int height)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Maui.Platform.Linux.Input;
|
||||
using Microsoft.Maui.Platform.Linux.Services;
|
||||
|
||||
namespace Microsoft.Maui.Platform.Linux.Window;
|
||||
|
||||
@@ -789,7 +790,7 @@ public class WaylandWindow : IDisposable
|
||||
// Create shared memory buffer
|
||||
CreateShmBuffer();
|
||||
|
||||
Console.WriteLine($"[Wayland] Window created: {_width}x{_height}");
|
||||
DiagnosticLog.Debug("WaylandWindow", $"Window created: {_width}x{_height}");
|
||||
}
|
||||
|
||||
private void CreateShmBuffer()
|
||||
@@ -910,7 +911,7 @@ public class WaylandWindow : IDisposable
|
||||
var window = (WaylandWindow)handle.Target!;
|
||||
|
||||
var interfaceName = Marshal.PtrToStringAnsi(iface);
|
||||
Console.WriteLine($"[Wayland] Global: {interfaceName} v{version}");
|
||||
DiagnosticLog.Debug("WaylandWindow", $"Global: {interfaceName} v{version}");
|
||||
|
||||
switch (interfaceName)
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
using Microsoft.Maui.Platform.Linux.Interop;
|
||||
using Microsoft.Maui.Platform.Linux.Input;
|
||||
using Microsoft.Maui.Platform.Linux.Services;
|
||||
using SkiaSharp;
|
||||
using Svg.Skia;
|
||||
|
||||
@@ -226,7 +227,7 @@ public class X11Window : IDisposable
|
||||
};
|
||||
|
||||
X11.XSetClassHint(_display, _window, ref classHint);
|
||||
Console.WriteLine($"[X11Window] Set WM_CLASS: {resName}, {resClass}");
|
||||
DiagnosticLog.Debug("X11Window", $"Set WM_CLASS: {resName}, {resClass}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -244,10 +245,10 @@ public class X11Window : IDisposable
|
||||
{
|
||||
if (string.IsNullOrEmpty(iconPath) || !System.IO.File.Exists(iconPath))
|
||||
{
|
||||
Console.WriteLine("[X11Window] Icon file not found: " + iconPath);
|
||||
DiagnosticLog.Warn("X11Window", "Icon file not found: " + iconPath);
|
||||
return;
|
||||
}
|
||||
Console.WriteLine("[X11Window] SetIcon called: " + iconPath);
|
||||
DiagnosticLog.Debug("X11Window", "SetIcon called: " + iconPath);
|
||||
try
|
||||
{
|
||||
SKBitmap? bitmap = null;
|
||||
@@ -255,7 +256,7 @@ public class X11Window : IDisposable
|
||||
// Handle SVG icons
|
||||
if (iconPath.EndsWith(".svg", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Console.WriteLine("[X11Window] Loading SVG icon");
|
||||
DiagnosticLog.Debug("X11Window", "Loading SVG icon");
|
||||
using var svg = new SKSvg();
|
||||
svg.Load(iconPath);
|
||||
if (svg.Picture != null)
|
||||
@@ -273,16 +274,16 @@ public class X11Window : IDisposable
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("[X11Window] Loading raster icon");
|
||||
DiagnosticLog.Debug("X11Window", "Loading raster icon");
|
||||
bitmap = SKBitmap.Decode(iconPath);
|
||||
}
|
||||
|
||||
if (bitmap == null)
|
||||
{
|
||||
Console.WriteLine("[X11Window] Failed to load icon: " + iconPath);
|
||||
DiagnosticLog.Warn("X11Window", "Failed to load icon: " + iconPath);
|
||||
return;
|
||||
}
|
||||
Console.WriteLine($"[X11Window] Loaded bitmap: {bitmap.Width}x{bitmap.Height}");
|
||||
DiagnosticLog.Debug("X11Window", $"Loaded bitmap: {bitmap.Width}x{bitmap.Height}");
|
||||
|
||||
// Scale to 64x64 if needed
|
||||
int targetSize = 64;
|
||||
@@ -318,11 +319,11 @@ public class X11Window : IDisposable
|
||||
X11.XChangeProperty(_display, _window, property, type, 32, 0, (nint)data, dataSize);
|
||||
}
|
||||
X11.XFlush(_display);
|
||||
Console.WriteLine($"[X11Window] Set window icon: {width}x{height}");
|
||||
DiagnosticLog.Debug("X11Window", $"Set window icon: {width}x{height}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("[X11Window] Failed to set icon: " + ex.Message);
|
||||
DiagnosticLog.Error("X11Window", "Failed to set icon", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,7 +451,7 @@ public class X11Window : IDisposable
|
||||
{
|
||||
if (_eventCounter % 100 == 0)
|
||||
{
|
||||
Console.WriteLine($"[X11Window] ProcessEvents: {pending} pending events");
|
||||
DiagnosticLog.Debug("X11Window", $"ProcessEvents: {pending} pending events");
|
||||
}
|
||||
_eventCounter++;
|
||||
while (X11.XPending(_display) > 0)
|
||||
|
||||
Reference in New Issue
Block a user