feat: Output progress information when executing commands.

执行命令时输出执行进度信息。
This commit is contained in:
real-zony 2021-06-02 21:54:39 +08:00
parent 420dc6bc04
commit 387e029c24
2 changed files with 14 additions and 0 deletions

View File

@ -142,6 +142,8 @@ namespace ZonyLrcTools.Cli.Commands
{
async Task<bool> InternalDownloadLogicAsync(ILyricDownloader downloader)
{
_logger.LogMusicInfoWithInformation(info);
try
{
var lyric = await downloader.DownloadAsync(info.Name, info.Artist);
@ -203,6 +205,8 @@ namespace ZonyLrcTools.Cli.Commands
private async Task DownloadAlbumTaskLogicAsync(IAlbumDownloader downloader, MusicInfo info)
{
_logger.LogMusicInfoWithInformation(info);
try
{
var album = await downloader.DownloadAsync(info.Name, info.Artist);

View File

@ -39,5 +39,15 @@ namespace ZonyLrcTools.Cli.Infrastructure.Extensions
sb.Append($"\n附加信息:\n {JsonConvert.SerializeObject(exception.AttachObject)}");
logger.LogWarning(sb.ToString());
}
/// <summary>
/// 使用 <see cref="LogLevel.Information"/> 级别打印歌曲信息。
/// </summary>
/// <param name="logger">日志记录器的实例。</param>
/// <param name="musicInfo">需要打印的歌曲信息。</param>
public static void LogMusicInfoWithInformation(this ILogger logger, MusicInfo musicInfo)
{
logger.LogInformation($"歌曲名: {musicInfo.Name}, 艺术家: {musicInfo.Artist}, 歌曲路径: {musicInfo.FilePath}");
}
}
}