| | | 1 | | using Anichron.Worker.Ingestion.Pipeline; |
| | | 2 | | |
| | | 3 | | namespace Anichron.Worker.Ingestion.Middlewares; |
| | | 4 | | |
| | 5 | 5 | | internal sealed partial class LoggingMiddleware(ILogger<LoggingMiddleware> logger) : IIngestionMiddleware |
| | | 6 | | { |
| | 0 | 7 | | public int Order => IngestionOrder.Logging; |
| | 0 | 8 | | public bool CanInvoke(IngestionContext context) => true; |
| | | 9 | | |
| | | 10 | | public async Task InvokeAsync(IngestionContext context, IngestionDelegate next, CancellationToken ct) |
| | 5 | 11 | | { |
| | 5 | 12 | | Log.ItemStarted(logger, context.Item.AbsolutePath); |
| | 5 | 13 | | await next(context, ct); |
| | 3 | 14 | | Log.ItemCompleted(logger, context.Item.AbsolutePath); |
| | 3 | 15 | | } |
| | | 16 | | |
| | | 17 | | private static partial class Log |
| | | 18 | | { |
| | | 19 | | [LoggerMessage(Level = LogLevel.Debug, Message = "Ingesting {Path}.")] |
| | | 20 | | public static partial void ItemStarted(ILogger logger, string path); |
| | | 21 | | |
| | | 22 | | [LoggerMessage(Level = LogLevel.Debug, Message = "Completed {Path}.")] |
| | | 23 | | public static partial void ItemCompleted(ILogger logger, string path); |
| | | 24 | | } |
| | | 25 | | } |