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>
68 lines
2.6 KiB
C#
68 lines
2.6 KiB
C#
using Chronos.Core.Diagnostics;
|
|
using CoreLogLevel = Chronos.Core.Diagnostics.LogLevel;
|
|
using MsLogLevel = Microsoft.Extensions.Logging.LogLevel;
|
|
|
|
namespace Chronos.Server.Hosting;
|
|
|
|
/// <summary>
|
|
/// In-house structured file logging for ASP.NET Core: the rotating files of <see cref="ServerLogging.Sink"/> under
|
|
/// /data/logs, at <see cref="ServerLogging.FileLevel"/> of the moment (owner review 2, R11: it was fixed at Information,
|
|
/// so Debug and Trace never reached the files).
|
|
/// </summary>
|
|
public sealed class FileLoggerProvider(ServerLogging logging) : ILoggerProvider
|
|
{
|
|
public ILogger CreateLogger(string categoryName) => new FileLogger(logging, categoryName);
|
|
|
|
public void Dispose() => logging.Sink.Dispose();
|
|
|
|
private sealed class FileLogger(ServerLogging logging, string category) : ILogger
|
|
{
|
|
public IDisposable? BeginScope<TState>(TState state) where TState : notnull => null;
|
|
|
|
public bool IsEnabled(MsLogLevel logLevel) => logLevel != MsLogLevel.None && logLevel >= logging.FileLevel;
|
|
|
|
public void Log<TState>(MsLogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
|
|
{
|
|
if (!IsEnabled(logLevel)) return;
|
|
logging.Sink.Write(ServerLogging.Core(logLevel), category, formatter(state, exception), exception);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>Bridges engine logging (Chronos.Core.Diagnostics.Log) into ASP.NET Core logging.</summary>
|
|
public sealed class LoggerSink(ILoggerFactory factory) : ILogSink
|
|
{
|
|
public void Write(CoreLogLevel level, string category, string message, Exception? exception)
|
|
{
|
|
ILogger logger;
|
|
try
|
|
{
|
|
logger = factory.CreateLogger("Chronos." + category);
|
|
}
|
|
catch (ObjectDisposedException)
|
|
{
|
|
// The host that installed this sink has shut down (engine code may outlive it); the line is dropped.
|
|
return;
|
|
}
|
|
var ms = level switch
|
|
{
|
|
CoreLogLevel.Trace => MsLogLevel.Trace,
|
|
CoreLogLevel.Debug => MsLogLevel.Debug,
|
|
CoreLogLevel.Info => MsLogLevel.Information,
|
|
CoreLogLevel.Warning => MsLogLevel.Warning,
|
|
_ => MsLogLevel.Error,
|
|
};
|
|
try
|
|
{
|
|
#pragma warning disable CA2254 // Engine messages are preformatted.
|
|
logger.Log(ms, exception, message);
|
|
#pragma warning restore CA2254
|
|
}
|
|
catch (AggregateException)
|
|
{
|
|
// A provider could not write it (Microsoft.Extensions.Logging gathers what they throw): the line is dropped, as
|
|
// Log.Write would drop it, so the engine code that logs goes on.
|
|
}
|
|
}
|
|
}
|