fix(logs): apply log settings from the first line and name the locking variable

The desktop opened its log files with the default limits and wrote its first
line, which prunes, before Settings › Advanced › Logs were applied. Every start,
and every launch that only hands its file to the running Chronos, deleted logs
older than 14 days and cut the folder to 1 GB whatever the user kept.
AppLogging.Open now builds the sink from the stored settings before that line;
the settings are read again once the launch owns the data folder.

A total below one file deleted each finished file as the next one opened. The
rule now lives in LogFileOptions.TotalBelowFile: the server keeps refusing it,
the desktop raises the total to the file size and its rows no longer offer the
combination.

The desktop log rows threw on negative sizes from an imported or hand-edited
file and showed raw values the files never got; they now show the applied ones.

Upgraded Unraid and compose installs keep CHRONOS_LOG_LEVEL=Information, which
locks both levels. The lock stays; the server now reports which variable fixes
each locked setting (LockedBy), so the panel's tooltip names it exactly and says
to remove it to change the value there. The releases README tells upgraders.

The former-constructor log test no longer fails across midnight UTC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 8ba7162bd5926d34c5ec4e40e2a2dad063ee19c3)
This commit is contained in:
Alby96 committed 2026-10-27 09:56:46 +01:00
1 parent 8d66be709c
commit ac121acf7c
53 files changed
+254 -92

No files matched your search

@@ -142,9 +142,12 @@ public sealed class FileLogSinkTests(TestContext context)
var sink = new FileLogSink(dir, "setup", 7);
Assert.Equal(new LogFileOptions { RetentionDays = 7 }, sink.Options);
Assert.Equal((LogLevel.Info, 50, 1024, LogRotation.Daily), (sink.Options.Level, sink.Options.MaxFileMb, sink.Options.MaxTotalMb, sink.Options.Rotation));
var before = DateTime.UtcNow;
sink.Write(LogLevel.Warning, "setup", "written", null);
var expected = Path.Combine(dir, $"setup-{DateTime.UtcNow:yyyyMMdd}.log");
Assert.Equal(expected, sink.CurrentPath);
var after = DateTime.UtcNow;
// The system clock: a write across midnight UTC names either day.
var expected = sink.CurrentPath;
Assert.Contains(expected, new[] { before, after }.Select(day => Path.Combine(dir, $"setup-{day:yyyyMMdd}.log")));
sink.Dispose();
// Engine code may log after the host closed its sink: the line is dropped.
sink.Write(LogLevel.Error, "setup", "after", null);