CI / Build and test (push) Successful in 7m0s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 13m28s
CI / PostgreSQL 16 integration (push) Successful in 5m52s
CI / PostgreSQL 17 integration (push) Successful in 4m50s
CI / Docker image (push) Successful in 1m4s
Release / Server image (push) Successful in 1m35s
- Jobs > Scheduled on the desktop and the admin panel. Every timer that queued work is now a visible system schedule: archive scan, upload clean-up, index backup, job-history and audit clean-ups, desktop housekeeping. New actions: verify, thumbnails, proxies, analysis, maintenance, backup, clean-ups, reports. - The scheduler: migration 0007, in-house recurrence, compare-and-set claim, catch-up, scan at start. - Log settings: levels, retention, size parts, total limit, daily or hourly rotation, audit retention, diagnostics share; the server writes Debug/Trace to its files again; logging never fails a job. Upgrade: CHRONOS_LOG_LEVEL set in an existing container locks both levels; migration 0007 is one-way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
71 lines
2.4 KiB
C#
71 lines
2.4 KiB
C#
using Chronos.Core.Diagnostics;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Core.Tests.Diagnostics;
|
|
|
|
/// <summary>
|
|
/// Logging never throws into the code that logs: the job engine and the scheduler log from their error handling, and a line
|
|
/// that escaped there once left a failed job running and could stop a worker. Serial: these tests replace the process-wide sink.
|
|
/// </summary>
|
|
[Serial]
|
|
public sealed class LogTests
|
|
{
|
|
/// <summary>Throws what Microsoft.Extensions.Logging throws when a file provider's folder is gone.</summary>
|
|
private sealed class BrokenSink : ILogSink
|
|
{
|
|
public int Calls;
|
|
|
|
public void Write(LogLevel level, string category, string message, Exception? exception)
|
|
{
|
|
Interlocked.Increment(ref Calls);
|
|
throw new AggregateException("An error occurred while writing to logger(s).", new DirectoryNotFoundException("Could not find a part of the path"));
|
|
}
|
|
}
|
|
|
|
private sealed class ListSink : ILogSink
|
|
{
|
|
public List<string> Lines { get; } = [];
|
|
|
|
public void Write(LogLevel level, string category, string message, Exception? exception)
|
|
{
|
|
lock (Lines) Lines.Add($"{level} {category}: {message}");
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void ALineASinkCannotWriteIsDroppedWithoutThrowing()
|
|
{
|
|
var sink = new BrokenSink();
|
|
var previous = Log.Sink;
|
|
var level = Log.MinimumLevel;
|
|
Log.SetSink(sink);
|
|
Log.MinimumLevel = LogLevel.Debug;
|
|
try
|
|
{
|
|
Log.Debug("test", "debug");
|
|
Log.Info("test", "info");
|
|
Log.Warning("test", "warning", new InvalidOperationException("cause"));
|
|
Log.Error("test", "error", new InvalidOperationException("cause"));
|
|
Log.Write(LogLevel.Error, "test", "write", null);
|
|
}
|
|
finally
|
|
{
|
|
Log.SetSink(previous);
|
|
Log.MinimumLevel = level;
|
|
}
|
|
Assert.Equal(5, sink.Calls);
|
|
}
|
|
|
|
[Test]
|
|
public void OneSinkOfATeeThatCannotWriteDoesNotKeepTheLineFromTheOthers()
|
|
{
|
|
var broken = new BrokenSink();
|
|
var kept = new ListSink();
|
|
var tee = new TeeLogSink(broken, kept);
|
|
tee.Write(LogLevel.Warning, "test", "first", null);
|
|
tee.Write(LogLevel.Error, "test", "second", new IOException("disk"));
|
|
Assert.Equal(2, broken.Calls);
|
|
Assert.SequenceEqual(["Warning test: first", "Error test: second"], kept.Lines);
|
|
}
|
|
}
|