Diagnostics slice of Phase 5 (builds on 5a's in-shell nav): - Structured logging: InMemoryLogStore now stores LogEntry (timestamp/level/message) + raises EntriesChanged; new ILogReader contract. A shared Serilog LoggingLevelSwitch (ILogLevelController) makes the level runtime-adjustable. ILogMaintenance exports a .zip (streams each log-*.txt with shared read so today's locked file is included), reports size, and deletes rolled files. - Log Viewer (in-shell section, Ctrl+L / Tools menu): live entries, level + text filter, per-level color (theme-safe; Information inherits body), auto-scroll, open-folder / export-.zip / clear. - Debug panel (in-shell, Tools + Settings>Advanced): verbose log dump, catalog counts + validation errors (now exposed via ICatalogProvider.ValidationErrors), system-info dump with copy. - Global crash handler: Dispatcher/AppDomain/TaskScheduler -> structured Serilog log (no sensitive data) + friendly ErrorDialog (message, error code, Copy details, Report bug, Close); re-entrancy guard; recovers dispatcher exceptions. - Report a bug (Help menu + from ErrorDialog): auto-gathered environment, export log .zip with review reminder, opens a prefilled GitHub issue. User-initiated; no auto-send (Privacy). - Settings: new Logs (level / size / open / export / clear) and Advanced (run mode / config path / open Debug panel / reset-to-defaults — preserves terms + logs) sections; ISettingsService.LogLevel persisted and applied at startup. EN/VI strings + AutomationProperties added. Dry-run deferred. 87 tests pass (store/filter/report-template/catalog-errors/settings/DI/resx); 0-warning Release build; Log Viewer smoke-verified live in dark mode. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
1016 B
C#
37 lines
1016 B
C#
using System.Globalization;
|
|
using CommandForge.Application.Logging;
|
|
|
|
namespace CommandForge.Wpf.ViewModels;
|
|
|
|
/// <summary>A single log line for display: formatted time, 3-letter level tag, message, and raw level.</summary>
|
|
public sealed class LogEntryViewModel
|
|
{
|
|
public LogEntryViewModel(LogEntry entry)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(entry);
|
|
Level = entry.Level;
|
|
Time = entry.Timestamp.ToLocalTime().ToString("HH:mm:ss", CultureInfo.CurrentCulture);
|
|
LevelTag = ToTag(entry.Level);
|
|
Message = entry.Message;
|
|
}
|
|
|
|
public LogLevel Level { get; }
|
|
|
|
public string Time { get; }
|
|
|
|
public string LevelTag { get; }
|
|
|
|
public string Message { get; }
|
|
|
|
private static string ToTag(LogLevel level) => level switch
|
|
{
|
|
LogLevel.Verbose => "VRB",
|
|
LogLevel.Debug => "DBG",
|
|
LogLevel.Information => "INF",
|
|
LogLevel.Warning => "WRN",
|
|
LogLevel.Error => "ERR",
|
|
LogLevel.Fatal => "FTL",
|
|
_ => "INF",
|
|
};
|
|
}
|