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:
@@ -36,7 +36,7 @@ public class AtSpi2AccessibilityService : IAccessibilityService, IDisposable
|
||||
int result = atspi_init();
|
||||
if (result != 0)
|
||||
{
|
||||
Console.WriteLine("AtSpi2AccessibilityService: Failed to initialize AT-SPI2");
|
||||
DiagnosticLog.Error("AtSpi2AccessibilityService", "Failed to initialize AT-SPI2");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,16 +51,16 @@ public class AtSpi2AccessibilityService : IAccessibilityService, IDisposable
|
||||
// Register our application
|
||||
RegisterApplication();
|
||||
|
||||
Console.WriteLine("AtSpi2AccessibilityService: Initialized successfully");
|
||||
DiagnosticLog.Debug("AtSpi2AccessibilityService", "Initialized successfully");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("AtSpi2AccessibilityService: Accessibility is not enabled");
|
||||
DiagnosticLog.Warn("AtSpi2AccessibilityService", "Accessibility is not enabled");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"AtSpi2AccessibilityService: Initialization failed - {ex.Message}");
|
||||
DiagnosticLog.Error("AtSpi2AccessibilityService", $"Initialization failed - {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,11 +168,11 @@ public class AtSpi2AccessibilityService : IAccessibilityService, IDisposable
|
||||
// or by emitting "object:announcement" events
|
||||
|
||||
// For now, use a simpler approach with the event system
|
||||
Console.WriteLine($"[Accessibility Announcement ({priority})]: {text}");
|
||||
DiagnosticLog.Debug("AtSpi2AccessibilityService", $"Announcement ({priority}): {text}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"AtSpi2AccessibilityService: Announcement failed - {ex.Message}");
|
||||
DiagnosticLog.Error("AtSpi2AccessibilityService", $"Announcement failed - {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ public class AtSpi2AccessibilityService : IAccessibilityService, IDisposable
|
||||
// using the org.a11y.atspi.Event interface
|
||||
|
||||
// For now, log the event for debugging
|
||||
Console.WriteLine($"[AT-SPI2 Event] {eventName}: {accessible.AccessibleName} ({accessible.Role})");
|
||||
DiagnosticLog.Debug("AtSpi2AccessibilityService", $"Event {eventName}: {accessible.AccessibleName} ({accessible.Role})");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
80
Services/DiagnosticLog.cs
Normal file
80
Services/DiagnosticLog.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Microsoft.Maui.Platform.Linux.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Centralized diagnostic logging for the Linux MAUI platform.
|
||||
/// Logging is enabled only in DEBUG builds by default, or when
|
||||
/// explicitly enabled via <see cref="IsEnabled"/>.
|
||||
/// </summary>
|
||||
public static class DiagnosticLog
|
||||
{
|
||||
private static bool? _isEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether diagnostic logging is enabled.
|
||||
/// Defaults to true in DEBUG builds, false in RELEASE builds.
|
||||
/// </summary>
|
||||
public static bool IsEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_isEnabled.HasValue)
|
||||
return _isEnabled.Value;
|
||||
#if DEBUG
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
set => _isEnabled = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs an informational diagnostic message.
|
||||
/// </summary>
|
||||
[Conditional("DEBUG")]
|
||||
public static void Debug(string tag, string message)
|
||||
{
|
||||
if (IsEnabled)
|
||||
System.Console.WriteLine($"[{tag}] {message}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs an informational diagnostic message (always writes when enabled, not conditional on DEBUG).
|
||||
/// Use for important operational messages that should appear in release builds when logging is enabled.
|
||||
/// </summary>
|
||||
public static void Info(string tag, string message)
|
||||
{
|
||||
if (IsEnabled)
|
||||
System.Console.WriteLine($"[{tag}] {message}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs a warning message. Always writes when logging is enabled.
|
||||
/// </summary>
|
||||
public static void Warn(string tag, string message)
|
||||
{
|
||||
if (IsEnabled)
|
||||
System.Console.Error.WriteLine($"[{tag}] WARNING: {message}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs an error message. Always writes regardless of IsEnabled.
|
||||
/// </summary>
|
||||
public static void Error(string tag, string message)
|
||||
{
|
||||
System.Console.Error.WriteLine($"[{tag}] ERROR: {message}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs an error message with exception details. Always writes regardless of IsEnabled.
|
||||
/// </summary>
|
||||
public static void Error(string tag, string message, Exception ex)
|
||||
{
|
||||
System.Console.Error.WriteLine($"[{tag}] ERROR: {message}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
@@ -29,12 +29,12 @@ public static class DisplayServerFactory
|
||||
|
||||
if (!string.IsNullOrEmpty(xDisplay) && !string.IsNullOrEmpty(preferX11))
|
||||
{
|
||||
Console.WriteLine("[DisplayServer] XWayland detected, using X11 backend (MAUI_PREFER_X11 set)");
|
||||
DiagnosticLog.Debug("DisplayServerFactory", "XWayland detected, using X11 backend (MAUI_PREFER_X11 set)");
|
||||
_cachedServerType = DisplayServerType.X11;
|
||||
return DisplayServerType.X11;
|
||||
}
|
||||
|
||||
Console.WriteLine("[DisplayServer] Wayland display detected");
|
||||
DiagnosticLog.Debug("DisplayServerFactory", "Wayland display detected");
|
||||
_cachedServerType = DisplayServerType.Wayland;
|
||||
return DisplayServerType.Wayland;
|
||||
}
|
||||
@@ -43,13 +43,13 @@ public static class DisplayServerFactory
|
||||
var x11Display = Environment.GetEnvironmentVariable("DISPLAY");
|
||||
if (!string.IsNullOrEmpty(x11Display))
|
||||
{
|
||||
Console.WriteLine("[DisplayServer] X11 display detected");
|
||||
DiagnosticLog.Debug("DisplayServerFactory", "X11 display detected");
|
||||
_cachedServerType = DisplayServerType.X11;
|
||||
return DisplayServerType.X11;
|
||||
}
|
||||
|
||||
// Default to X11 and let it fail if not available
|
||||
Console.WriteLine("[DisplayServer] No display server detected, defaulting to X11");
|
||||
DiagnosticLog.Warn("DisplayServerFactory", "No display server detected, defaulting to X11");
|
||||
_cachedServerType = DisplayServerType.X11;
|
||||
return DisplayServerType.X11;
|
||||
}
|
||||
@@ -76,12 +76,12 @@ public static class DisplayServerFactory
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine($"[DisplayServer] Creating X11 window: {title} ({width}x{height})");
|
||||
DiagnosticLog.Debug("DisplayServerFactory", $"Creating X11 window: {title} ({width}x{height})");
|
||||
return new X11DisplayWindow(title, width, height);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[DisplayServer] Failed to create X11 window: {ex.Message}");
|
||||
DiagnosticLog.Error("DisplayServerFactory", $"Failed to create X11 window: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -90,18 +90,18 @@ public static class DisplayServerFactory
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine($"[DisplayServer] Creating Wayland window: {title} ({width}x{height})");
|
||||
DiagnosticLog.Debug("DisplayServerFactory", $"Creating Wayland window: {title} ({width}x{height})");
|
||||
return new WaylandDisplayWindow(title, width, height);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[DisplayServer] Failed to create Wayland window: {ex.Message}");
|
||||
DiagnosticLog.Error("DisplayServerFactory", $"Failed to create Wayland window: {ex.Message}");
|
||||
|
||||
// Try to fall back to X11 via XWayland
|
||||
var xDisplay = Environment.GetEnvironmentVariable("DISPLAY");
|
||||
if (!string.IsNullOrEmpty(xDisplay))
|
||||
{
|
||||
Console.WriteLine("[DisplayServer] Falling back to X11 (XWayland)");
|
||||
DiagnosticLog.Warn("DisplayServerFactory", "Falling back to X11 (XWayland)");
|
||||
return CreateX11Window(title, width, height);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,18 +48,18 @@ public class Fcitx5InputMethodService : IInputMethodService, IDisposable
|
||||
if (start >= 0 && end > start)
|
||||
{
|
||||
_inputContextPath = output.Substring(start + 1, end - start - 1);
|
||||
Console.WriteLine($"Fcitx5InputMethodService: Created context at {_inputContextPath}");
|
||||
DiagnosticLog.Debug("Fcitx5InputMethodService", $"Created context at {_inputContextPath}");
|
||||
StartMonitoring();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Fcitx5InputMethodService: Failed to create input context");
|
||||
DiagnosticLog.Error("Fcitx5InputMethodService", "Failed to create input context");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Fcitx5InputMethodService: Initialization failed - {ex.Message}");
|
||||
DiagnosticLog.Error("Fcitx5InputMethodService", $"Initialization failed - {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class Fcitx5InputMethodService : IInputMethodService, IDisposable
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Fcitx5InputMethodService: Monitor error - {ex.Message}");
|
||||
DiagnosticLog.Error("Fcitx5InputMethodService", $"Monitor error - {ex.Message}");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public class FilePickerService : IFilePicker
|
||||
if (tool == DialogTool.None)
|
||||
{
|
||||
// Fall back to console path input
|
||||
Console.WriteLine("No file dialog available. Please enter file path:");
|
||||
DiagnosticLog.Warn("FilePickerService", "No file dialog available. Please enter file path:");
|
||||
var path = Console.ReadLine();
|
||||
if (!string.IsNullOrEmpty(path) && File.Exists(path))
|
||||
{
|
||||
|
||||
@@ -76,7 +76,7 @@ public class GlobalHotkeyService : IDisposable
|
||||
int result = XGrabKey(_display, keyCode, mask, _rootWindow, true, GrabModeAsync, GrabModeAsync);
|
||||
if (result == 0)
|
||||
{
|
||||
Console.WriteLine($"Failed to grab key {key} with modifiers {modifiers}");
|
||||
DiagnosticLog.Warn("GlobalHotkeyService", $"Failed to grab key {key} with modifiers {modifiers}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public class GlobalHotkeyService : IDisposable
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"GlobalHotkeyService error: {ex.Message}");
|
||||
DiagnosticLog.Error("GlobalHotkeyService", $"Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,17 +295,17 @@ public class Gtk4InteropService : IDisposable
|
||||
{
|
||||
_useGtk4 = true;
|
||||
_initialized = true;
|
||||
Console.WriteLine("[GTK4] Initialized GTK4");
|
||||
DiagnosticLog.Debug("Gtk4InteropService", "Initialized GTK4");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (DllNotFoundException)
|
||||
{
|
||||
Console.WriteLine("[GTK4] GTK4 not found, trying GTK3");
|
||||
DiagnosticLog.Warn("Gtk4InteropService", "GTK4 not found, trying GTK3");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[GTK4] GTK4 init failed: {ex.Message}");
|
||||
DiagnosticLog.Error("Gtk4InteropService", $"GTK4 init failed: {ex.Message}");
|
||||
}
|
||||
|
||||
// Fall back to GTK3
|
||||
@@ -317,17 +317,17 @@ public class Gtk4InteropService : IDisposable
|
||||
{
|
||||
_useGtk4 = false;
|
||||
_initialized = true;
|
||||
Console.WriteLine("[GTK4] Initialized GTK3 (fallback)");
|
||||
DiagnosticLog.Debug("Gtk4InteropService", "Initialized GTK3 (fallback)");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (DllNotFoundException)
|
||||
{
|
||||
Console.WriteLine("[GTK4] GTK3 not found");
|
||||
DiagnosticLog.Warn("Gtk4InteropService", "GTK3 not found");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[GTK4] GTK3 init failed: {ex.Message}");
|
||||
DiagnosticLog.Error("Gtk4InteropService", $"GTK3 init failed: {ex.Message}");
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -31,7 +31,7 @@ public static class GtkContextMenuService
|
||||
IntPtr menu = GtkNative.gtk_menu_new();
|
||||
if (menu == IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine("[GtkContextMenuService] Failed to create GTK menu");
|
||||
DiagnosticLog.Error("GtkContextMenuService", "Failed to create GTK menu");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public static class GtkContextMenuService
|
||||
|
||||
ActivateCallback callback = delegate
|
||||
{
|
||||
Console.WriteLine("[GtkContextMenuService] Menu item activated: " + item.Text);
|
||||
DiagnosticLog.Debug("GtkContextMenuService", "Menu item activated: " + item.Text);
|
||||
_actions[actionIndex]?.Invoke();
|
||||
};
|
||||
_callbacks.Add(callback);
|
||||
@@ -88,7 +88,7 @@ public static class GtkContextMenuService
|
||||
GtkNative.gdk_event_free(currentEvent);
|
||||
}
|
||||
|
||||
Console.WriteLine($"[GtkContextMenuService] Showed GTK menu with {items.Count} items");
|
||||
DiagnosticLog.Debug("GtkContextMenuService", $"Showed GTK menu with {items.Count} items");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -107,7 +107,7 @@ public static class GtkContextMenuService
|
||||
isDark = Microsoft.Maui.Controls.Application.Current?.RequestedTheme == Microsoft.Maui.ApplicationModel.AppTheme.Dark;
|
||||
}
|
||||
|
||||
Console.WriteLine($"[GtkContextMenuService] ApplyMenuTheme: isDark={isDark}");
|
||||
DiagnosticLog.Debug("GtkContextMenuService", $"ApplyMenuTheme: isDark={isDark}");
|
||||
|
||||
// Create comprehensive CSS based on the theme
|
||||
string css = isDark
|
||||
@@ -164,7 +164,7 @@ public static class GtkContextMenuService
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[GtkContextMenuService] Error applying menu theme: {ex.Message}");
|
||||
DiagnosticLog.Error("GtkContextMenuService", $"Error applying menu theme: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public static class GtkThemeService
|
||||
isDark = Microsoft.Maui.Controls.Application.Current?.RequestedTheme == Microsoft.Maui.ApplicationModel.AppTheme.Dark;
|
||||
}
|
||||
|
||||
Console.WriteLine($"[GtkThemeService] ApplyTheme: isDark={isDark}");
|
||||
DiagnosticLog.Debug("GtkThemeService", $"ApplyTheme: isDark={isDark}");
|
||||
|
||||
// Create comprehensive CSS based on the theme
|
||||
string css = isDark ? GetDarkCss() : GetLightCss();
|
||||
@@ -47,7 +47,7 @@ public static class GtkThemeService
|
||||
IntPtr screen = GtkNative.gdk_screen_get_default();
|
||||
if (screen == IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine("[GtkThemeService] Failed to get default screen");
|
||||
DiagnosticLog.Error("GtkThemeService", "Failed to get default screen");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -55,14 +55,14 @@ public static class GtkThemeService
|
||||
IntPtr newProvider = GtkNative.gtk_css_provider_new();
|
||||
if (newProvider == IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine("[GtkThemeService] Failed to create CSS provider");
|
||||
DiagnosticLog.Error("GtkThemeService", "Failed to create CSS provider");
|
||||
return;
|
||||
}
|
||||
|
||||
// Load CSS data
|
||||
if (!GtkNative.gtk_css_provider_load_from_data(newProvider, css, -1, IntPtr.Zero))
|
||||
{
|
||||
Console.WriteLine("[GtkThemeService] Failed to load CSS data");
|
||||
DiagnosticLog.Error("GtkThemeService", "Failed to load CSS data");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -72,11 +72,11 @@ public static class GtkThemeService
|
||||
// Store reference to current provider
|
||||
_currentCssProvider = newProvider;
|
||||
|
||||
Console.WriteLine("[GtkThemeService] CSS applied successfully");
|
||||
DiagnosticLog.Debug("GtkThemeService", "CSS applied successfully");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[GtkThemeService] Error applying theme: {ex.Message}");
|
||||
DiagnosticLog.Error("GtkThemeService", $"Error applying theme: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ public class HardwareVideoService : IDisposable
|
||||
{
|
||||
_currentApi = VideoAccelerationApi.VaApi;
|
||||
_initialized = true;
|
||||
Console.WriteLine($"[HardwareVideo] Initialized VA-API with {_supportedProfiles.Count} supported profiles");
|
||||
DiagnosticLog.Debug("HardwareVideoService", $"Initialized VA-API with {_supportedProfiles.Count} supported profiles");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -216,12 +216,12 @@ public class HardwareVideoService : IDisposable
|
||||
{
|
||||
_currentApi = VideoAccelerationApi.Vdpau;
|
||||
_initialized = true;
|
||||
Console.WriteLine("[HardwareVideo] Initialized VDPAU");
|
||||
DiagnosticLog.Debug("HardwareVideoService", "Initialized VDPAU");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("[HardwareVideo] No hardware acceleration available, using software");
|
||||
DiagnosticLog.Warn("HardwareVideoService", "No hardware acceleration available, using software");
|
||||
_currentApi = VideoAccelerationApi.Software;
|
||||
return false;
|
||||
}
|
||||
@@ -261,12 +261,12 @@ public class HardwareVideoService : IDisposable
|
||||
}
|
||||
catch (DllNotFoundException)
|
||||
{
|
||||
Console.WriteLine("[HardwareVideo] VA-API libraries not found");
|
||||
DiagnosticLog.Warn("HardwareVideoService", "VA-API libraries not found");
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[HardwareVideo] VA-API initialization failed: {ex.Message}");
|
||||
DiagnosticLog.Error("HardwareVideoService", $"VA-API initialization failed: {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -276,11 +276,11 @@ public class HardwareVideoService : IDisposable
|
||||
int status = vaInitialize(_vaDisplay, out int major, out int minor);
|
||||
if (status != VA_STATUS_SUCCESS)
|
||||
{
|
||||
Console.WriteLine($"[HardwareVideo] vaInitialize failed: {GetVaError(status)}");
|
||||
DiagnosticLog.Error("HardwareVideoService", $"vaInitialize failed: {GetVaError(status)}");
|
||||
return false;
|
||||
}
|
||||
|
||||
Console.WriteLine($"[HardwareVideo] VA-API {major}.{minor} initialized");
|
||||
DiagnosticLog.Debug("HardwareVideoService", $"VA-API {major}.{minor} initialized");
|
||||
|
||||
// Query supported profiles
|
||||
int[] profiles = new int[32];
|
||||
@@ -331,11 +331,11 @@ public class HardwareVideoService : IDisposable
|
||||
}
|
||||
catch (DllNotFoundException)
|
||||
{
|
||||
Console.WriteLine("[HardwareVideo] VDPAU libraries not found");
|
||||
DiagnosticLog.Warn("HardwareVideoService", "VDPAU libraries not found");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[HardwareVideo] VDPAU initialization failed: {ex.Message}");
|
||||
DiagnosticLog.Error("HardwareVideoService", $"VDPAU initialization failed: {ex.Message}");
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -355,7 +355,7 @@ public class HardwareVideoService : IDisposable
|
||||
|
||||
if (!_supportedProfiles.Contains(profile))
|
||||
{
|
||||
Console.WriteLine($"[HardwareVideo] Profile {profile} not supported");
|
||||
DiagnosticLog.Warn("HardwareVideoService", $"Profile {profile} not supported");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ public class HardwareVideoService : IDisposable
|
||||
int status = vaCreateConfig(_vaDisplay, vaProfile, VAEntrypointVLD, IntPtr.Zero, 0, out _vaConfigId);
|
||||
if (status != VA_STATUS_SUCCESS)
|
||||
{
|
||||
Console.WriteLine($"[HardwareVideo] vaCreateConfig failed: {GetVaError(status)}");
|
||||
DiagnosticLog.Error("HardwareVideoService", $"vaCreateConfig failed: {GetVaError(status)}");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ public class HardwareVideoService : IDisposable
|
||||
status = vaCreateSurfaces(_vaDisplay, format, (uint)width, (uint)height, _vaSurfaces, 8, IntPtr.Zero, 0);
|
||||
if (status != VA_STATUS_SUCCESS)
|
||||
{
|
||||
Console.WriteLine($"[HardwareVideo] vaCreateSurfaces failed: {GetVaError(status)}");
|
||||
DiagnosticLog.Error("HardwareVideoService", $"vaCreateSurfaces failed: {GetVaError(status)}");
|
||||
vaDestroyConfig(_vaDisplay, _vaConfigId);
|
||||
return false;
|
||||
}
|
||||
@@ -405,13 +405,13 @@ public class HardwareVideoService : IDisposable
|
||||
status = vaCreateContext(_vaDisplay, _vaConfigId, width, height, 0, IntPtr.Zero, 0, out _vaContextId);
|
||||
if (status != VA_STATUS_SUCCESS)
|
||||
{
|
||||
Console.WriteLine($"[HardwareVideo] vaCreateContext failed: {GetVaError(status)}");
|
||||
DiagnosticLog.Error("HardwareVideoService", $"vaCreateContext failed: {GetVaError(status)}");
|
||||
vaDestroySurfaces(_vaDisplay, _vaSurfaces, _vaSurfaces.Length);
|
||||
vaDestroyConfig(_vaDisplay, _vaConfigId);
|
||||
return false;
|
||||
}
|
||||
|
||||
Console.WriteLine($"[HardwareVideo] Created decoder: {profile} {width}x{height}");
|
||||
DiagnosticLog.Debug("HardwareVideoService", $"Created decoder: {profile} {width}x{height}");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,14 +45,14 @@ public class IBusInputMethodService : IInputMethodService, IDisposable
|
||||
_bus = ibus_bus_new();
|
||||
if (_bus == IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine("IBusInputMethodService: Failed to connect to IBus");
|
||||
DiagnosticLog.Error("IBusInputMethodService", "Failed to connect to IBus");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if IBus is connected
|
||||
if (!ibus_bus_is_connected(_bus))
|
||||
{
|
||||
Console.WriteLine("IBusInputMethodService: IBus not connected");
|
||||
DiagnosticLog.Error("IBusInputMethodService", "IBus not connected");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class IBusInputMethodService : IInputMethodService, IDisposable
|
||||
_context = ibus_bus_create_input_context(_bus, "maui-linux");
|
||||
if (_context == IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine("IBusInputMethodService: Failed to create input context");
|
||||
DiagnosticLog.Error("IBusInputMethodService", "Failed to create input context");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -71,11 +71,11 @@ public class IBusInputMethodService : IInputMethodService, IDisposable
|
||||
// Connect signals
|
||||
ConnectSignals();
|
||||
|
||||
Console.WriteLine("IBusInputMethodService: Initialized successfully");
|
||||
DiagnosticLog.Debug("IBusInputMethodService", "Initialized successfully");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"IBusInputMethodService: Initialization failed - {ex.Message}");
|
||||
DiagnosticLog.Error("IBusInputMethodService", $"Initialization failed - {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,33 +63,33 @@ public static class InputMethodServiceFactory
|
||||
// Try Fcitx5 first if it's the configured IM
|
||||
if (imModule?.Contains("fcitx") == true && Fcitx5InputMethodService.IsAvailable())
|
||||
{
|
||||
Console.WriteLine("InputMethodServiceFactory: Using Fcitx5");
|
||||
DiagnosticLog.Debug("InputMethodServiceFactory", "Using Fcitx5");
|
||||
return CreateFcitx5Service();
|
||||
}
|
||||
|
||||
// Try IBus (most common on modern Linux)
|
||||
if (IsIBusAvailable())
|
||||
{
|
||||
Console.WriteLine("InputMethodServiceFactory: Using IBus");
|
||||
DiagnosticLog.Debug("InputMethodServiceFactory", "Using IBus");
|
||||
return CreateIBusService();
|
||||
}
|
||||
|
||||
// Try Fcitx5 as fallback
|
||||
if (Fcitx5InputMethodService.IsAvailable())
|
||||
{
|
||||
Console.WriteLine("InputMethodServiceFactory: Using Fcitx5");
|
||||
DiagnosticLog.Debug("InputMethodServiceFactory", "Using Fcitx5");
|
||||
return CreateFcitx5Service();
|
||||
}
|
||||
|
||||
// Fall back to XIM
|
||||
if (IsXIMAvailable())
|
||||
{
|
||||
Console.WriteLine("InputMethodServiceFactory: Using XIM");
|
||||
DiagnosticLog.Debug("InputMethodServiceFactory", "Using XIM");
|
||||
return CreateXIMService();
|
||||
}
|
||||
|
||||
// No IME available
|
||||
Console.WriteLine("InputMethodServiceFactory: No IME available, using null service");
|
||||
DiagnosticLog.Warn("InputMethodServiceFactory", "No IME available, using null service");
|
||||
return new NullInputMethodService();
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public static class InputMethodServiceFactory
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"InputMethodServiceFactory: Failed to create IBus service - {ex.Message}");
|
||||
DiagnosticLog.Error("InputMethodServiceFactory", $"Failed to create IBus service - {ex.Message}");
|
||||
return new NullInputMethodService();
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public static class InputMethodServiceFactory
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"InputMethodServiceFactory: Failed to create Fcitx5 service - {ex.Message}");
|
||||
DiagnosticLog.Error("InputMethodServiceFactory", $"Failed to create Fcitx5 service - {ex.Message}");
|
||||
return new NullInputMethodService();
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public static class InputMethodServiceFactory
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"InputMethodServiceFactory: Failed to create XIM service - {ex.Message}");
|
||||
DiagnosticLog.Error("InputMethodServiceFactory", $"Failed to create XIM service - {ex.Message}");
|
||||
return new NullInputMethodService();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public static class MauiIconGenerator
|
||||
{
|
||||
if (!File.Exists(metaFilePath))
|
||||
{
|
||||
Console.WriteLine("[MauiIconGenerator] Metadata file not found: " + metaFilePath);
|
||||
DiagnosticLog.Error("MauiIconGenerator", "Metadata file not found: " + metaFilePath);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -48,9 +48,9 @@ public static class MauiIconGenerator
|
||||
? scaleVal
|
||||
: 0.65f;
|
||||
|
||||
Console.WriteLine($"[MauiIconGenerator] Generating {size}x{size} icon");
|
||||
Console.WriteLine($"[MauiIconGenerator] Color: {color}");
|
||||
Console.WriteLine($"[MauiIconGenerator] Scale: {scale}");
|
||||
DiagnosticLog.Debug("MauiIconGenerator", $"Generating {size}x{size} icon");
|
||||
DiagnosticLog.Debug("MauiIconGenerator", $" Color: {color}");
|
||||
DiagnosticLog.Debug("MauiIconGenerator", $" Scale: {scale}");
|
||||
|
||||
using var surface = SKSurface.Create(new SKImageInfo(size, size, SKColorType.Bgra8888, SKAlphaType.Premul));
|
||||
var canvas = surface.Canvas;
|
||||
@@ -82,12 +82,12 @@ public static class MauiIconGenerator
|
||||
using var fileStream = File.OpenWrite(outputPath);
|
||||
data.SaveTo(fileStream);
|
||||
|
||||
Console.WriteLine("[MauiIconGenerator] Generated: " + outputPath);
|
||||
DiagnosticLog.Debug("MauiIconGenerator", "Generated: " + outputPath);
|
||||
return outputPath;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("[MauiIconGenerator] Error: " + ex.Message);
|
||||
DiagnosticLog.Error("MauiIconGenerator", "Error: " + ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class MonitorService : IDisposable
|
||||
_display = X11.XOpenDisplay(IntPtr.Zero);
|
||||
if (_display == IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine("[MonitorService] Failed to open X11 display");
|
||||
DiagnosticLog.Error("MonitorService", "Failed to open X11 display");
|
||||
_initialized = true;
|
||||
return;
|
||||
}
|
||||
@@ -117,26 +117,26 @@ public class MonitorService : IDisposable
|
||||
// Check if XRandR is available
|
||||
if (XRandR.XRRQueryExtension(_display, out _eventBase, out _errorBase) == 0)
|
||||
{
|
||||
Console.WriteLine("[MonitorService] XRandR extension not available");
|
||||
DiagnosticLog.Warn("MonitorService", "XRandR extension not available");
|
||||
_initialized = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (XRandR.XRRQueryVersion(_display, out int major, out int minor) == 0)
|
||||
{
|
||||
Console.WriteLine("[MonitorService] Failed to query XRandR version");
|
||||
DiagnosticLog.Error("MonitorService", "Failed to query XRandR version");
|
||||
_initialized = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine($"[MonitorService] XRandR {major}.{minor} available");
|
||||
DiagnosticLog.Debug("MonitorService", $"XRandR {major}.{minor} available");
|
||||
|
||||
RefreshMonitors();
|
||||
_initialized = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[MonitorService] Initialization failed: {ex.Message}");
|
||||
DiagnosticLog.Error("MonitorService", $"Initialization failed: {ex.Message}");
|
||||
_initialized = true;
|
||||
}
|
||||
}
|
||||
@@ -157,7 +157,7 @@ public class MonitorService : IDisposable
|
||||
resources = XRandR.XRRGetScreenResourcesCurrent(_display, _rootWindow);
|
||||
if (resources == IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine("[MonitorService] Failed to get screen resources");
|
||||
DiagnosticLog.Error("MonitorService", "Failed to get screen resources");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -252,10 +252,10 @@ public class MonitorService : IDisposable
|
||||
_monitors = newMonitors;
|
||||
|
||||
// Log detected monitors
|
||||
Console.WriteLine($"[MonitorService] Detected {_monitors.Count} monitor(s):");
|
||||
DiagnosticLog.Debug("MonitorService", $"Detected {_monitors.Count} monitor(s):");
|
||||
foreach (var monitor in _monitors)
|
||||
{
|
||||
Console.WriteLine($" {monitor}");
|
||||
DiagnosticLog.Debug("MonitorService", $" {monitor}");
|
||||
}
|
||||
|
||||
// Notify if configuration changed
|
||||
|
||||
@@ -104,7 +104,7 @@ public class NotificationService
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[NotificationService] D-Bus monitor error: {ex.Message}");
|
||||
DiagnosticLog.Error("NotificationService", $"D-Bus monitor error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public class PortalFilePickerService : IFilePicker
|
||||
else
|
||||
{
|
||||
// No file picker available
|
||||
Console.WriteLine("[FilePickerService] No file picker available (install xdg-desktop-portal, zenity, or kdialog)");
|
||||
DiagnosticLog.Warn("PortalFilePickerService", "No file picker available (install xdg-desktop-portal, zenity, or kdialog)");
|
||||
return Enumerable.Empty<FileResult>();
|
||||
}
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public class PortalFilePickerService : IFilePicker
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[FilePickerService] Portal error: {ex.Message}");
|
||||
DiagnosticLog.Error("PortalFilePickerService", $"Portal error: {ex.Message}");
|
||||
// Fall back to zenity/kdialog
|
||||
if (_fallbackTool != null)
|
||||
{
|
||||
@@ -358,7 +358,7 @@ public class PortalFilePickerService : IFilePicker
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[FilePickerService] Command error: {ex.Message}");
|
||||
DiagnosticLog.Error("PortalFilePickerService", $"Command error: {ex.Message}");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,14 +392,14 @@ public class SystemThemeService
|
||||
|
||||
if (oldTheme != CurrentTheme)
|
||||
{
|
||||
Console.WriteLine($"[SystemThemeService] Theme change detected via polling: {oldTheme} -> {CurrentTheme}");
|
||||
DiagnosticLog.Debug("SystemThemeService", $"Theme change detected via polling: {oldTheme} -> {CurrentTheme}");
|
||||
UpdateColors();
|
||||
ThemeChanged?.Invoke(this, new ThemeChangedEventArgs(CurrentTheme));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[SystemThemeService] Error in poll timer: {ex.Message}");
|
||||
DiagnosticLog.Error("SystemThemeService", $"Error in poll timer: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class X11InputMethodService : IInputMethodService, IDisposable
|
||||
_display = XOpenDisplay(IntPtr.Zero);
|
||||
if (_display == IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine("X11InputMethodService: Failed to open display");
|
||||
DiagnosticLog.Error("X11InputMethodService", "Failed to open display");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class X11InputMethodService : IInputMethodService, IDisposable
|
||||
_xim = XOpenIM(_display, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
|
||||
if (_xim == IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine("X11InputMethodService: No input method available, trying IBus...");
|
||||
DiagnosticLog.Warn("X11InputMethodService", "No input method available, trying IBus...");
|
||||
TryIBusFallback();
|
||||
return;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class X11InputMethodService : IInputMethodService, IDisposable
|
||||
|
||||
if (_xic != IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine("X11InputMethodService: Input context created successfully");
|
||||
DiagnosticLog.Debug("X11InputMethodService", "Input context created successfully");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ public class X11InputMethodService : IInputMethodService, IDisposable
|
||||
{
|
||||
// Try to connect to IBus via D-Bus
|
||||
// This provides a more modern IME interface
|
||||
Console.WriteLine("X11InputMethodService: IBus fallback not yet implemented");
|
||||
DiagnosticLog.Warn("X11InputMethodService", "IBus fallback not yet implemented");
|
||||
}
|
||||
|
||||
public void SetFocus(IInputContext? context)
|
||||
|
||||
Reference in New Issue
Block a user