refactor: Refactor lyrics download logic and abstract a new logger.

This commit is contained in:
real-zony
2022-10-23 13:38:51 +08:00
parent 3e27e18098
commit 7d17fc0b97
18 changed files with 245 additions and 163 deletions

View File

@@ -4,16 +4,17 @@ using Microsoft.Extensions.Logging.Abstractions;
using ZonyLrcTools.Common.Infrastructure.DependencyInject;
using ZonyLrcTools.Common.Infrastructure.Exceptions;
using ZonyLrcTools.Common.Infrastructure.Extensions;
using ZonyLrcTools.Common.Infrastructure.Logging;
namespace ZonyLrcTools.Common.Infrastructure.IO
{
public class FileScanner : IFileScanner, ITransientDependency
{
public ILogger<FileScanner> Logger { get; set; }
private readonly IWarpLogger _logger;
public FileScanner()
public FileScanner(IWarpLogger logger)
{
Logger = NullLogger<FileScanner>.Instance;
_logger = logger;
}
public Task<List<FileScannerResult>> ScanAsync(string path, IEnumerable<string> extensions)
@@ -58,7 +59,7 @@ namespace ZonyLrcTools.Common.Infrastructure.IO
}
catch (Exception e)
{
Logger.LogWarningWithErrorCode(ErrorCodes.ScanFileError, e);
_logger.LogWarningWithErrorCode(ErrorCodes.ScanFileError, e);
}
}
}