diff --git a/README.md b/README.md
index 6cb04b0e..213ae2f8 100644
--- a/README.md
+++ b/README.md
@@ -452,7 +452,7 @@ Right now, we are compatible with version 11. If you need to make changes, you c
Here are some things you can do to figure out how to get your app running:
-* Make sure you have enabled and debugged your application thoroughly. A great way to do this is to set `SparkleUpdater.LogWriter = new LogWriter(true)` and then watch your console output while debugging.
+* Make sure you have enabled and debugged your application thoroughly. A great way to do this is to set `SparkleUpdater.LogWriter = new LogWriter(LogWriterOutputMode.Console)` and then watch your console output while debugging.
* Look at the NetSparkleUpdater samples by downloading this repo and running the samples. You can even try putting your app cast URL in there and using your public key to debug with the source code!
* Ask for help in our [Gitter](https://gitter.im/NetSparkleUpdater/NetSparkle)
* Post an issue and wait for someone to respond with assistance
diff --git a/UPGRADING.md b/UPGRADING.md
index 6826f866..f71d2fb7 100644
--- a/UPGRADING.md
+++ b/UPGRADING.md
@@ -25,6 +25,12 @@
* `AssemblyReflectionAccessor` has been deprecated. Please use `AsmResolverAccessor` instead. (#587)
* `AssemblyDiagnosticAccessor.AssemblyVersion` now returns `FileVersionInfo.GetVersionInfo(assemblyName).ProductVersion` rather than `FileVersionInfo.GetVersionInfo(assemblyName).FileVersion` so we can get semver versioning information
* For ed25519 use, changed from BouncyCastle to Chaos.NaCl (large file size savings and we don't need all of BouncyCastle's features). You can verify its use and code online here: https://github.com/NetSparkleUpdater/Chaos.NaCl. Additionally, this package is available on NuGet for your own projects.
+* `LogWriter` has undergone several changes:
+ * `public static string tag = "netsparkle:";` has changed to `public string Tag { get; set; } = "netsparkle:";`
+ * Instead of a simple `bool` to control printing to `Trace.WriteLine` or `Console.WriteLine`, there is now a new enum, `NetSparkleUpdater.Enums.LogWriterOutputMode`, which you can use to control whether `LogWriter` outputs to `Console`, `Trace`, `Debug`, or to `None` (don't output at all).
+ * Removed `PrintDiagnosticToConsole` property and replaced it with `OutputMode` of type `LogWriterOutputMode`.
+ * The default print mode for `LogWriter` is still `Trace` by default, as it was in prior versions.
+ * By default, timestamps are now output along with the `Tag` and actual log item
**Changes/Fixes**
diff --git a/nuget/winformsnetframework/NetSparkleUpdater.UI.WinForms.NetFramework.nuspec b/nuget/winformsnetframework/NetSparkleUpdater.UI.WinForms.NetFramework.nuspec
index 28fa9b83..beb6705c 100644
--- a/nuget/winformsnetframework/NetSparkleUpdater.UI.WinForms.NetFramework.nuspec
+++ b/nuget/winformsnetframework/NetSparkleUpdater.UI.WinForms.NetFramework.nuspec
@@ -27,5 +27,6 @@
+
diff --git a/src/NetSparkle.Samples.Avalonia.MacOS/MainWindow.axaml.cs b/src/NetSparkle.Samples.Avalonia.MacOS/MainWindow.axaml.cs
index f1f516d9..28fa9cff 100644
--- a/src/NetSparkle.Samples.Avalonia.MacOS/MainWindow.axaml.cs
+++ b/src/NetSparkle.Samples.Avalonia.MacOS/MainWindow.axaml.cs
@@ -3,8 +3,8 @@
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.Media.Imaging;
+using NetSparkleUpdater.Enums;
using NetSparkleUpdater.SignatureVerifiers;
-using NetSparkleUpdater.UI.Avalonia;
using System.IO;
namespace NetSparkleUpdater.Samples.Avalonia
@@ -23,7 +23,7 @@ public MainWindow()
UIFactory = new NetSparkleUpdater.UI.Avalonia.UIFactory(Icon),
// Avalonia version doesn't support separate threads: https://github.com/AvaloniaUI/Avalonia/issues/3434#issuecomment-573446972
ShowsUIOnMainThread = true,
- LogWriter = new LogWriter(true)
+ LogWriter = new LogWriter(LogWriterOutputMode.Console)
//UseNotificationToast = false // Avalonia version doesn't yet support notification toast messages
};
// TLS 1.2 required by GitHub (https://developer.github.com/changes/2018-02-01-weak-crypto-removal-notice/)
diff --git a/src/NetSparkle.Samples.Avalonia.MacOSZip/MainWindow.axaml.cs b/src/NetSparkle.Samples.Avalonia.MacOSZip/MainWindow.axaml.cs
index 326ea93a..4f78fc36 100644
--- a/src/NetSparkle.Samples.Avalonia.MacOSZip/MainWindow.axaml.cs
+++ b/src/NetSparkle.Samples.Avalonia.MacOSZip/MainWindow.axaml.cs
@@ -26,7 +26,7 @@ public MainWindow()
UIFactory = new NetSparkleUpdater.UI.Avalonia.UIFactory(Icon),
// Avalonia version doesn't support separate threads: https://github.com/AvaloniaUI/Avalonia/issues/3434#issuecomment-573446972
ShowsUIOnMainThread = true,
- LogWriter = new LogWriter(true),
+ LogWriter = new LogWriter(),
RelaunchAfterUpdate = true,
//UseNotificationToast = false // Avalonia version doesn't yet support notification toast messages
diff --git a/src/NetSparkle.Tests.AppCastGenerator/AppCastMakerTests.cs b/src/NetSparkle.Tests.AppCastGenerator/AppCastMakerTests.cs
index daee1b4a..a45fc3da 100644
--- a/src/NetSparkle.Tests.AppCastGenerator/AppCastMakerTests.cs
+++ b/src/NetSparkle.Tests.AppCastGenerator/AppCastMakerTests.cs
@@ -1,13 +1,9 @@
using NetSparkleUpdater.AppCastGenerator;
-using Org.BouncyCastle.Crypto;
-using Org.BouncyCastle.Crypto.Generators;
-using Org.BouncyCastle.Crypto.Parameters;
+using NetSparkleUpdater.Enums;
using Org.BouncyCastle.Security;
using System;
using System.IO;
using System.Linq;
-using System.Text;
-using System.Runtime.CompilerServices;
using Xunit;
using System.Runtime.InteropServices;
using System.Diagnostics;
@@ -771,7 +767,7 @@ public void NetSparkleCanParseHumanReadableAppCast()
new NetSparkleUpdater.SignatureVerifiers.Ed25519Checker(
NetSparkleUpdater.Enums.SecurityMode.Strict,
publicKeyString),
- new NetSparkleUpdater.LogWriter(true));
+ new NetSparkleUpdater.LogWriter(LogWriterOutputMode.Console));
var didSucceed = appCastHandler.DownloadAndParse();
Assert.True(didSucceed);
var updates = appCastHandler.GetAvailableUpdates();
@@ -938,7 +934,7 @@ public void CanSetCriticalVersion()
new NetSparkleUpdater.SignatureVerifiers.Ed25519Checker(
NetSparkleUpdater.Enums.SecurityMode.Strict,
publicKeyString),
- new NetSparkleUpdater.LogWriter(true));
+ new NetSparkleUpdater.LogWriter(LogWriterOutputMode.Console));
var didSucceed = appCastHandler.DownloadAndParse();
Assert.True(didSucceed);
var updates = appCastHandler.GetAvailableUpdates();
diff --git a/src/NetSparkle.Tools.AppCastGenerator/XMLAppCastMaker.cs b/src/NetSparkle.Tools.AppCastGenerator/XMLAppCastMaker.cs
index 16c35b8d..aee01288 100644
--- a/src/NetSparkle.Tools.AppCastGenerator/XMLAppCastMaker.cs
+++ b/src/NetSparkle.Tools.AppCastGenerator/XMLAppCastMaker.cs
@@ -1,4 +1,5 @@
using NetSparkleUpdater.AppCastHandlers;
+using NetSparkleUpdater.Enums;
using System;
using System.Collections.Generic;
using System.Drawing;
@@ -56,7 +57,7 @@ public override (List, string) GetItemsAndProductNameFromExistingAp
}
var docDescendants = doc.Descendants("item");
- var logWriter = new LogWriter(true);
+ var logWriter = new LogWriter(LogWriterOutputMode.Console);
foreach (var item in docDescendants)
{
var currentItem = AppCastItem.Parse("", "", "/", item, logWriter);
diff --git a/src/NetSparkle/Enums/LogWriterOutputMode.cs b/src/NetSparkle/Enums/LogWriterOutputMode.cs
new file mode 100644
index 00000000..a777055f
--- /dev/null
+++ b/src/NetSparkle/Enums/LogWriterOutputMode.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Diagnostics;
+
+namespace NetSparkleUpdater.Enums
+{
+ ///
+ /// Output mode for the class
+ ///
+ public enum LogWriterOutputMode
+ {
+ ///
+ /// Don't output anything
+ ///
+ None = 0,
+ ///
+ /// Output to
+ ///
+ Console = 1,
+ ///
+ /// Output to
+ ///
+ Trace = 2,
+ ///
+ /// Output to
+ ///
+ Debug = 3
+ }
+}
diff --git a/src/NetSparkle/LogWriter.cs b/src/NetSparkle/LogWriter.cs
index 95a37f18..c1197940 100644
--- a/src/NetSparkle/LogWriter.cs
+++ b/src/NetSparkle/LogWriter.cs
@@ -1,66 +1,68 @@
using NetSparkleUpdater.Enums;
using NetSparkleUpdater.Interfaces;
using System;
-using System.Collections.Generic;
using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace NetSparkleUpdater
{
///
- /// A simple class to handle log information for NetSparkleUpdater.
+ /// A simple class to handle logging information.
/// Make sure to do any setup for this class that you want
/// to do before calling StartLoop on your object.
///
public class LogWriter : ILogger
{
///
- /// Tag to show before any log statements
+ /// Tag to show before any log statements. Can be set to null.
///
- public static string tag = "netsparkle:";
+ public string Tag { get; set; } = "netsparkle:";
///
- /// Empty constructor -> sets PrintDiagnosticToConsole to false
+ /// Create a LogWriter that outputs to by default
///
public LogWriter()
{
- PrintDiagnosticToConsole = false;
+ OutputMode = LogWriterOutputMode.Trace;
}
///
- /// LogWriter constructor that takes a bool to determine
- /// the value for printDiagnosticToConsole
+ /// Create a LogWriter that outputs via the given LogWriterOutputMode mode
///
- /// False to print to ;
- /// true to print to
- public LogWriter(bool printDiagnosticToConsole)
+ /// for this LogWriter instance;
+ public LogWriter(LogWriterOutputMode outputMode)
{
- PrintDiagnosticToConsole = printDiagnosticToConsole;
+ OutputMode = outputMode;
}
#region Properties
///
- /// True if this class should print to ;
- /// false if this object should print to .
- /// Defaults to false.
+ /// for this LogWriter instance. Set to
+ /// to make this LogWriter output nothing.
///
- public bool PrintDiagnosticToConsole { get; set; }
+ public LogWriterOutputMode OutputMode { get; set; }
#endregion
///
public virtual void PrintMessage(string message, params object[] arguments)
{
- if (PrintDiagnosticToConsole)
+ var timestamp = string.Format("[{0:s}]", DateTime.Now);
+ switch (OutputMode)
{
- Console.WriteLine(tag + " " + message, arguments);
- }
- else
- {
- Trace.WriteLine(string.Format(tag + " " + message, arguments));
+ case LogWriterOutputMode.Console:
+ Console.WriteLine(timestamp + " " + Tag + (string.IsNullOrWhiteSpace(Tag) ? "" : " ") + message, arguments);
+ break;
+ case LogWriterOutputMode.Trace:
+ Trace.WriteLine(string.Format(timestamp + " " + Tag + (string.IsNullOrWhiteSpace(Tag) ? "" : " ") + message, arguments));
+ break;
+ case LogWriterOutputMode.Debug:
+ Debug.WriteLine(timestamp + " " + Tag + (string.IsNullOrWhiteSpace(Tag) ? "" : " ") + message, arguments);
+ break;
+ case LogWriterOutputMode.None:
+ break;
+ default:
+ break;
}
}
}