From ddce528a3e4a7e3bb993d1f07a4c0eb661189118 Mon Sep 17 00:00:00 2001
From: "coderabbitai[bot]"
<136622811+coderabbitai[bot]@users.noreply.github.com>
Date: Wed, 12 Mar 2025 00:57:19 +0000
Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20docstrings=20to=20`debug-l?=
=?UTF-8?q?og-level`?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Docstrings generation was requested by @VictoriousRaptor.
* https://github.com/Flow-Launcher/Flow.Launcher/pull/2739#issuecomment-2714878609
The following files were modified:
* `Flow.Launcher.Infrastructure/Logger/Log.cs`
* `Flow.Launcher/App.xaml.cs`
---
Flow.Launcher.Infrastructure/Logger/Log.cs | 23 +++++++++++++++++++++-
Flow.Launcher/App.xaml.cs | 11 ++++++++++-
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/Flow.Launcher.Infrastructure/Logger/Log.cs b/Flow.Launcher.Infrastructure/Logger/Log.cs
index 3eb53e0a3eb..2b692d9466c 100644
--- a/Flow.Launcher.Infrastructure/Logger/Log.cs
+++ b/Flow.Launcher.Infrastructure/Logger/Log.cs
@@ -1,4 +1,4 @@
-using System.Diagnostics;
+using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using NLog;
@@ -16,6 +16,14 @@ public static class Log
public static string CurrentLogDirectory { get; }
+ ///
+ /// Initializes the logging infrastructure for the Log class by configuring the log directory and NLog targets.
+ ///
+ ///
+ /// This static constructor sets up the current log directory based on the application's data directory, ensuring it exists before any logging occurs.
+ /// It configures an asynchronous file logging target with a predefined message layout and, in debug builds, an additional debug output target.
+ /// Logging rules are established for both targets to ensure a consistent logging format throughout the application.
+ ///
static Log()
{
CurrentLogDirectory = Path.Combine(DataLocation.DataDirectory(), DirectoryName, Constant.Version);
@@ -63,18 +71,31 @@ static Log()
LogManager.Configuration = configuration;
}
+ ///
+ /// Configures the file logging rule to capture logs from Debug to Fatal.
+ ///
+ ///
+ /// This method updates the logging configuration by locating the rule named "file" and setting its logging levels to include Debug messages, ensuring detailed log output. It then logs an informational message indicating that the DEBUG log level is now active.
+ ///
public static void UseDebugLogLevel()
{
LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Debug, LogLevel.Fatal);
Info(nameof(Logger), "Using DEBUG log level.");
}
+ ///
+ /// Configures the file logging target to record messages from Info to Fatal level and logs an informational message indicating that the INFO log level is in use.
+ ///
public static void UseInfoLogLevel()
{
LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Info, LogLevel.Fatal);
Info(nameof(Logger), "Using INFO log level.");
}
+ ///
+ /// Logs a fatal error indicating that a log message does not adhere to the expected format.
+ ///
+ /// The original log message that failed to meet the required format.
private static void LogFaultyFormat(string message)
{
var logger = LogManager.GetLogger("FaultyLogger");
diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs
index 6ec0424b863..1f2516fe73a 100644
--- a/Flow.Launcher/App.xaml.cs
+++ b/Flow.Launcher/App.xaml.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Diagnostics;
using System.Text;
using System.Threading;
@@ -108,6 +108,15 @@ public static void Main()
}
}
+ ///
+ /// Asynchronously executes the startup initialization sequence for the application.
+ ///
+ ///
+ /// This method performs pre-start cleanup, registers global exception handlers, configures logging
+ /// based on user settings, initializes images and plugins, and sets up internationalization and theme settings.
+ /// It also creates and displays the main window while registering exit events and enabling auto-startup and
+ /// periodic update checks to ensure a fully configured runtime environment.
+ ///
private async void OnStartupAsync(object sender, StartupEventArgs e)
{
await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>