Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion Flow.Launcher.Infrastructure/Logger/Log.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using NLog;
Expand All @@ -16,6 +16,14 @@ public static class Log

public static string CurrentLogDirectory { get; }

/// <summary>
/// Initializes the logging infrastructure for the Log class by configuring the log directory and NLog targets.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
static Log()
{
CurrentLogDirectory = Path.Combine(DataLocation.DataDirectory(), DirectoryName, Constant.Version);
Expand Down Expand Up @@ -63,18 +71,31 @@ static Log()
LogManager.Configuration = configuration;
}

/// <summary>
/// Configures the file logging rule to capture logs from Debug to Fatal.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
public static void UseDebugLogLevel()
{
LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Debug, LogLevel.Fatal);
Info(nameof(Logger), "Using DEBUG log level.");
}

/// <summary>
/// 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.
/// </summary>
public static void UseInfoLogLevel()
{
LogManager.Configuration.FindRuleByName("file").SetLoggingLevels(LogLevel.Info, LogLevel.Fatal);
Info(nameof(Logger), "Using INFO log level.");
}

/// <summary>
/// Logs a fatal error indicating that a log message does not adhere to the expected format.
/// </summary>
/// <param name="message">The original log message that failed to meet the required format.</param>
private static void LogFaultyFormat(string message)
{
var logger = LogManager.GetLogger("FaultyLogger");
Expand Down
11 changes: 10 additions & 1 deletion Flow.Launcher/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Diagnostics;
using System.Text;
using System.Threading;
Expand Down Expand Up @@ -108,6 +108,15 @@ public static void Main()
}
}

/// <summary>
/// Asynchronously executes the startup initialization sequence for the application.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
private async void OnStartupAsync(object sender, StartupEventArgs e)
{
await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
Expand Down
Loading