Files
AppKit/samples/AppKit.Sample.Wpf/Program.cs
T
james.maesandCodex 7f70c31517 feat(logging): preserve structured templates, fields, and scopes
Adapt existing IActivityLog sinks to standard ILogger without adding interface
requirements. Store original templates, rendered messages, typed JSON scalar
fields, event identity and async scopes. Preserve full exception text, daily
retention, failure containment, and thread-safe writes.

Migrate update events, framework crash nets and samples to source-generated
logging. Pin Microsoft.Extensions.Logging.Abstractions 10.0.12 (MIT) rather
than implementing template parsing. Advance the unreleased minor to 0.2.0
and document legacy API compatibility and explicit scalar/JSON value policy.

Validation: 146 unit tests, 12 sample UI tests, 100% core/updates coverage,
zero-warning build, formatting and hooks passed. Dependency scan reported
no known vulnerabilities. Starter migration and public rollout remain #5.

Refs: #5, #8
Co-Authored-By: Codex (GPT-6) <noreply@openai.com>
Signed-off-by: James Maes <james@kof22.com>
2026-10-10 13:07:45 -05:00

45 lines
1.4 KiB
C#

/*
* Copyright (c) 2026 James Maes (KofTwentyTwo)
* SPDX-License-Identifier: MIT
*/
using System.Windows;
using KofTwentyTwo.AppKit.Logging;
using KofTwentyTwo.AppKit.Updates;
using KofTwentyTwo.AppKit.Wpf;
using Microsoft.Extensions.Logging;
namespace AppKit.Sample.Wpf;
/// <summary>Entry point: Velopack hooks first, then the WPF application.</summary>
public static partial class Program
{
/// <summary>The app-wide activity log.</summary>
internal static IActivityLog Log { get; } = FileActivityLog.ForApp(SampleApp.Info, SampleApp.Paths);
/// <summary>The shared structured logger, including scopes.</summary>
internal static ILogger Logger { get; } = Log.AsLogger();
/// <summary>Runs Velopack&apos;s install and update hooks first, then creates the WPF application with AppKit&apos;s crash net and theme and shows the main window.</summary>
[STAThread]
private static void Main()
{
VelopackStartup.Run();
var app = new Application { ShutdownMode = ShutdownMode.OnMainWindowClose };
WpfShell.InstallCrashNet(app, () => Log);
WpfShell.ApplyTheme(app, SampleApp.SettingsStore.Load().ThemeKind);
LogStarted(Logger, SampleApp.Info.DisplayName);
app.Run(new MainWindow());
}
/// <summary>Records startup with the app identity as a field.</summary>
[LoggerMessage(100, LogLevel.Information, "{AppName} (WPF) started.")]
private static partial void LogStarted(ILogger logger, string appName);
}