diff --git a/src/NetSparkle/Downloaders/WebRequestAppCastDataDownloader.cs b/src/NetSparkle/Downloaders/WebRequestAppCastDataDownloader.cs index 2b25ab35..1a508644 100644 --- a/src/NetSparkle/Downloaders/WebRequestAppCastDataDownloader.cs +++ b/src/NetSparkle/Downloaders/WebRequestAppCastDataDownloader.cs @@ -1,4 +1,4 @@ -using NetSparkleUpdater.Interfaces; +using NetSparkleUpdater.Interfaces; using System; using System.Collections.Generic; using System.IO; @@ -18,16 +18,36 @@ namespace NetSparkleUpdater.Downloaders /// public class WebRequestAppCastDataDownloader : IAppCastDataDownloader { + private ILogger _logger; private string _appcastUrl = ""; /// - /// Default constructor for the app cast data downloader. Basically - /// does nothing. :) + /// Default constructor for the app cast data downloader. /// - public WebRequestAppCastDataDownloader() + public WebRequestAppCastDataDownloader() : this(new LogWriter()) { } + /// + /// Default constructor for the app cast data downloader. + /// + /// ILogger to write logs to + public WebRequestAppCastDataDownloader(ILogger logger) + { + if (logger == null) + throw new ArgumentNullException("logger"); + _logger = logger; + } + + /// + /// ILogger to log data from WebRequestAppCastDataDownloader + /// + public ILogger LogWriter + { + set { _logger = value; } + get { return _logger; } + } + /// /// If true, don't check the validity of SSL certificates. Defaults to false. /// @@ -132,7 +152,7 @@ public async Task DownloadAndGetAppCastDataAsync(string url) } catch (Exception e) { - Console.WriteLine(e.Message); + LogWriter.PrintMessage("Error: {0}", e.Message); } return ""; } diff --git a/src/NetSparkle/SparkleUpdater.cs b/src/NetSparkle/SparkleUpdater.cs index 71e9e0dc..7fc1e336 100644 --- a/src/NetSparkle/SparkleUpdater.cs +++ b/src/NetSparkle/SparkleUpdater.cs @@ -620,7 +620,7 @@ protected async Task GetUpdateStatus(Configuration config, bool igno // init the appcast if (AppCastDataDownloader == null) { - AppCastDataDownloader = new WebRequestAppCastDataDownloader(); + AppCastDataDownloader = new WebRequestAppCastDataDownloader(LogWriter); } if (AppCastHandler == null) {