FastGithub/FastGithub.Scanner/Middlewares/ScanOkLogMiddleware.cs
2021-06-15 23:51:11 +08:00

29 lines
738 B
C#

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;
namespace FastGithub.Scanner.Middlewares
{
[Service(ServiceLifetime.Singleton)]
sealed class ScanOkLogMiddleware : IGithubScanMiddleware
{
private readonly ILogger<ScanOkLogMiddleware> logger;
public ScanOkLogMiddleware(ILogger<ScanOkLogMiddleware> logger)
{
this.logger = logger;
}
public Task InvokeAsync(GithubContext context, Func<Task> next)
{
if (context.HttpElapsed != null)
{
this.logger.LogInformation(context.ToString());
}
return next();
}
}
}