Skip to content

Commit

Permalink
Merge pull request #522 from mgnslndh/gh-477
Browse files Browse the repository at this point in the history
Replace Console.WriteLine with LogWriter.PrintMessage
  • Loading branch information
Deadpikle authored Oct 23, 2023
2 parents 4257e35 + e48fe8b commit 26f156a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
30 changes: 25 additions & 5 deletions src/NetSparkle/Downloaders/WebRequestAppCastDataDownloader.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NetSparkleUpdater.Interfaces;
using NetSparkleUpdater.Interfaces;
using System;
using System.Collections.Generic;
using System.IO;
Expand All @@ -18,16 +18,36 @@ namespace NetSparkleUpdater.Downloaders
/// </summary>
public class WebRequestAppCastDataDownloader : IAppCastDataDownloader
{
private ILogger _logger;
private string _appcastUrl = "";

/// <summary>
/// Default constructor for the app cast data downloader. Basically
/// does nothing. :)
/// Default constructor for the app cast data downloader.
/// </summary>
public WebRequestAppCastDataDownloader()
public WebRequestAppCastDataDownloader() : this(new LogWriter())
{
}

/// <summary>
/// Default constructor for the app cast data downloader.
/// </summary>
/// <param name="logger">ILogger to write logs to</param>
public WebRequestAppCastDataDownloader(ILogger logger)
{
if (logger == null)
throw new ArgumentNullException("logger");
_logger = logger;
}

/// <summary>
/// ILogger to log data from WebRequestAppCastDataDownloader
/// </summary>
public ILogger LogWriter
{
set { _logger = value; }
get { return _logger; }
}

/// <summary>
/// If true, don't check the validity of SSL certificates. Defaults to false.
/// </summary>
Expand Down Expand Up @@ -132,7 +152,7 @@ public async Task<string> DownloadAndGetAppCastDataAsync(string url)
}
catch (Exception e)
{
Console.WriteLine(e.Message);
LogWriter.PrintMessage("Error: {0}", e.Message);
}
return "";
}
Expand Down
2 changes: 1 addition & 1 deletion src/NetSparkle/SparkleUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ protected async Task<UpdateInfo> GetUpdateStatus(Configuration config, bool igno
// init the appcast
if (AppCastDataDownloader == null)
{
AppCastDataDownloader = new WebRequestAppCastDataDownloader();
AppCastDataDownloader = new WebRequestAppCastDataDownloader(LogWriter);
}
if (AppCastHandler == null)
{
Expand Down

0 comments on commit 26f156a

Please sign in to comment.