|
|
|
@ -1,13 +1,16 @@
|
|
|
|
|
using System.IO.Abstractions;
|
|
|
|
|
using Serilog.Events;
|
|
|
|
|
using Serilog.Formatting;
|
|
|
|
|
using Serilog.Formatting.Display;
|
|
|
|
|
using TrashLib;
|
|
|
|
|
|
|
|
|
|
namespace Recyclarr.Logging;
|
|
|
|
|
|
|
|
|
|
public class DelayedFileSink : IDelayedFileSink
|
|
|
|
|
public sealed class DelayedFileSink : IDelayedFileSink
|
|
|
|
|
{
|
|
|
|
|
private readonly IAppPaths _paths;
|
|
|
|
|
private readonly Lazy<StreamWriter> _stream;
|
|
|
|
|
private ITextFormatter? _formatter;
|
|
|
|
|
|
|
|
|
|
public DelayedFileSink(IAppPaths paths, IFileSystem fs)
|
|
|
|
|
{
|
|
|
|
@ -26,7 +29,8 @@ public class DelayedFileSink : IDelayedFileSink
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_stream.Value.WriteLine(logEvent.RenderMessage());
|
|
|
|
|
_formatter?.Format(logEvent, _stream.Value);
|
|
|
|
|
_stream.Value.Flush();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
@ -36,4 +40,9 @@ public class DelayedFileSink : IDelayedFileSink
|
|
|
|
|
_stream.Value.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetTemplate(string template)
|
|
|
|
|
{
|
|
|
|
|
_formatter = new MessageTemplateTextFormatter(template);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|