rdt-client/server/RdtClient.Service/Helpers/Logger.cs
Roger Far cd6002b5d6 Upgrade packages
Moved C# code to file scoped namespaces
Merged Startup.cs and Program.cs
2022-04-30 11:22:15 -06:00

28 lines
No EOL
811 B
C#

using System.Web;
using RdtClient.Data.Models.Data;
namespace RdtClient.Service.Helpers;
public static class Logger
{
public static String ToLog(this Download download)
{
var fileName = download.Path;
if (!String.IsNullOrWhiteSpace(download.Link))
{
var uri = new Uri(download.Link);
fileName = uri.Segments.Last();
fileName = HttpUtility.UrlDecode(fileName);
}
var done = (Int32)((Double)download.BytesDone / download.BytesTotal) * 100;
return $"for download {fileName} {done}% ({download.DownloadId})";
}
public static String ToLog(this Torrent torrent)
{
return $"for torrent {torrent.RdName} ({torrent.RdId} - {torrent.RdStatusRaw} {torrent.RdProgress}%) ({torrent.TorrentId})";
}
}