mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-10 05:06:36 +02:00
Better logger
1. Throw exception for fatal/error log when debugging 2. Write to debug output for warn/debug/info log when debugging 3. part of #355
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using NLog;
|
||||
using Wox.Core.Exception;
|
||||
|
||||
namespace Wox.Infrastructure.Logger
|
||||
{
|
||||
@@ -7,34 +8,40 @@ namespace Wox.Infrastructure.Logger
|
||||
{
|
||||
private static NLog.Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public static void Error(string msg)
|
||||
{
|
||||
logger.Error(msg);
|
||||
}
|
||||
|
||||
public static void Error(Exception e)
|
||||
{
|
||||
#if DEBUG
|
||||
throw e;
|
||||
#else
|
||||
logger.Error(e.Message + "\r\n" + e.StackTrace);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void Debug(string msg)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"DEBUG: {msg}");
|
||||
logger.Debug(msg);
|
||||
}
|
||||
|
||||
public static void Info(string msg)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"INFO: {msg}");
|
||||
logger.Info(msg);
|
||||
}
|
||||
|
||||
public static void Warn(string msg)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"WARN: {msg}");
|
||||
logger.Warn(msg);
|
||||
}
|
||||
|
||||
public static void Fatal(string msg)
|
||||
public static void Fatal(Exception e)
|
||||
{
|
||||
logger.Fatal(msg);
|
||||
#if DEBUG
|
||||
throw e;
|
||||
#else
|
||||
logger.Fatal(ExceptionFormatter.FormatExcpetion(e));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user