From 0c762e610f311c2f9261a8ffd0f07e8b1d8cb8e2 Mon Sep 17 00:00:00 2001
From: AT <14300910+theClueless@users.noreply.github.com>
Date: Sat, 16 Nov 2019 00:57:30 +0200
Subject: [PATCH] fixed broken log
---
.../Logger/ProgramLogger.cs | 59 +++++++++++--------
Plugins/Wox.Plugin.Program/Programs/UWP.cs | 2 +-
2 files changed, 37 insertions(+), 24 deletions(-)
diff --git a/Plugins/Wox.Plugin.Program/Logger/ProgramLogger.cs b/Plugins/Wox.Plugin.Program/Logger/ProgramLogger.cs
index c8a104b101..aaf816e418 100644
--- a/Plugins/Wox.Plugin.Program/Logger/ProgramLogger.cs
+++ b/Plugins/Wox.Plugin.Program/Logger/ProgramLogger.cs
@@ -40,21 +40,11 @@ namespace Wox.Plugin.Program.Logger
LogManager.Configuration = configuration;
}
- ///
- /// Please follow exception format: |class name|calling method name|loading program path|user friendly message that explains the error
- /// => Example: |Win32|LnkProgram|c:\..\chrome.exe|Permission denied on directory, but Wox should continue
- ///
[MethodImpl(MethodImplOptions.Synchronized)]
- internal static void LogException(string message, Exception e)
+ internal static void LogException(string classname, string callingMethodName, string loadingProgramPath,
+ string interpretationMessage, Exception e)
{
- //Index 0 is always empty.
- var parts = message.Split('|');
- var classname = parts[1];
- var callingMethodName = parts[2];
- var loadingProgramPath = parts[3];
- var interpretationMessage = parts[4];
-
- Debug.WriteLine($"ERROR{message}");
+ Debug.WriteLine($"ERROR{classname}|{callingMethodName}|{loadingProgramPath}|{interpretationMessage}");
var logger = LogManager.GetLogger("");
@@ -78,16 +68,16 @@ namespace Wox.Plugin.Program.Logger
calledMethod = string.IsNullOrEmpty(calledMethod) ? "Not available" : calledMethod;
logger.Error($"\nException full name: {e.GetType().FullName}"
- + $"\nError status: {errorStatus}"
- + $"\nClass name: {classname}"
- + $"\nCalling method: {callingMethodName}"
- + $"\nProgram path: {loadingProgramPath}"
- + $"\nInnerException number: {innerExceptionNumber}"
- + $"\nException message: {e.Message}"
- + $"\nException error type: HResult {e.HResult}"
- + $"\nException thrown in called method: {calledMethod}"
- + $"\nPossible interpretation of the error: {interpretationMessage}"
- + $"\nPossible resolution: {possibleResolution}");
+ + $"\nError status: {errorStatus}"
+ + $"\nClass name: {classname}"
+ + $"\nCalling method: {callingMethodName}"
+ + $"\nProgram path: {loadingProgramPath}"
+ + $"\nInnerException number: {innerExceptionNumber}"
+ + $"\nException message: {e.Message}"
+ + $"\nException error type: HResult {e.HResult}"
+ + $"\nException thrown in called method: {calledMethod}"
+ + $"\nPossible interpretation of the error: {interpretationMessage}"
+ + $"\nPossible resolution: {possibleResolution}");
innerExceptionNumber++;
e = e.InnerException;
@@ -96,6 +86,29 @@ namespace Wox.Plugin.Program.Logger
logger.Error("------------- END Wox.Plugin.Program exception -------------");
}
+ ///
+ /// Please follow exception format: |class name|calling method name|loading program path|user friendly message that explains the error
+ /// => Example: |Win32|LnkProgram|c:\..\chrome.exe|Permission denied on directory, but Wox should continue
+ ///
+ [MethodImpl(MethodImplOptions.Synchronized)]
+ internal static void LogException(string message, Exception e)
+ {
+ //Index 0 is always empty.
+ var parts = message.Split('|');
+ if (parts.Length < 4)
+ {
+ var logger = LogManager.GetLogger("");
+ logger.Error(e, $"fail to log exception in program logger, parts length is too small: {parts.Length}, message: {message}");
+ }
+
+ var classname = parts[1];
+ var callingMethodName = parts[2];
+ var loadingProgramPath = parts[3];
+ var interpretationMessage = parts[4];
+
+ LogException(classname, callingMethodName, loadingProgramPath, interpretationMessage, e);
+ }
+
private static bool IsKnownWinProgramError(Exception e, string callingMethodName)
{
if (e.TargetSite?.Name == "GetDescription" && callingMethodName == "LnkProgram")
diff --git a/Plugins/Wox.Plugin.Program/Programs/UWP.cs b/Plugins/Wox.Plugin.Program/Programs/UWP.cs
index d511888ab0..d4a0596657 100644
--- a/Plugins/Wox.Plugin.Program/Programs/UWP.cs
+++ b/Plugins/Wox.Plugin.Program/Programs/UWP.cs
@@ -205,7 +205,7 @@ namespace Wox.Plugin.Program.Programs
}
catch (Exception e)
{
- ProgramLogger.LogException("|UWP|CurrentUserPackages|An unexpected error occured and "
+ ProgramLogger.LogException("UWP" ,"CurrentUserPackages", $"id","An unexpected error occured and "
+ $"unable to verify if package is valid", e);
return false;
}