mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
fixed broken log
This commit is contained in:
@@ -40,21 +40,11 @@ namespace Wox.Plugin.Program.Logger
|
|||||||
LogManager.Configuration = configuration;
|
LogManager.Configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 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
|
|
||||||
/// </summary>
|
|
||||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
[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.
|
Debug.WriteLine($"ERROR{classname}|{callingMethodName}|{loadingProgramPath}|{interpretationMessage}");
|
||||||
var parts = message.Split('|');
|
|
||||||
var classname = parts[1];
|
|
||||||
var callingMethodName = parts[2];
|
|
||||||
var loadingProgramPath = parts[3];
|
|
||||||
var interpretationMessage = parts[4];
|
|
||||||
|
|
||||||
Debug.WriteLine($"ERROR{message}");
|
|
||||||
|
|
||||||
var logger = LogManager.GetLogger("");
|
var logger = LogManager.GetLogger("");
|
||||||
|
|
||||||
@@ -78,16 +68,16 @@ namespace Wox.Plugin.Program.Logger
|
|||||||
calledMethod = string.IsNullOrEmpty(calledMethod) ? "Not available" : calledMethod;
|
calledMethod = string.IsNullOrEmpty(calledMethod) ? "Not available" : calledMethod;
|
||||||
|
|
||||||
logger.Error($"\nException full name: {e.GetType().FullName}"
|
logger.Error($"\nException full name: {e.GetType().FullName}"
|
||||||
+ $"\nError status: {errorStatus}"
|
+ $"\nError status: {errorStatus}"
|
||||||
+ $"\nClass name: {classname}"
|
+ $"\nClass name: {classname}"
|
||||||
+ $"\nCalling method: {callingMethodName}"
|
+ $"\nCalling method: {callingMethodName}"
|
||||||
+ $"\nProgram path: {loadingProgramPath}"
|
+ $"\nProgram path: {loadingProgramPath}"
|
||||||
+ $"\nInnerException number: {innerExceptionNumber}"
|
+ $"\nInnerException number: {innerExceptionNumber}"
|
||||||
+ $"\nException message: {e.Message}"
|
+ $"\nException message: {e.Message}"
|
||||||
+ $"\nException error type: HResult {e.HResult}"
|
+ $"\nException error type: HResult {e.HResult}"
|
||||||
+ $"\nException thrown in called method: {calledMethod}"
|
+ $"\nException thrown in called method: {calledMethod}"
|
||||||
+ $"\nPossible interpretation of the error: {interpretationMessage}"
|
+ $"\nPossible interpretation of the error: {interpretationMessage}"
|
||||||
+ $"\nPossible resolution: {possibleResolution}");
|
+ $"\nPossible resolution: {possibleResolution}");
|
||||||
|
|
||||||
innerExceptionNumber++;
|
innerExceptionNumber++;
|
||||||
e = e.InnerException;
|
e = e.InnerException;
|
||||||
@@ -96,6 +86,29 @@ namespace Wox.Plugin.Program.Logger
|
|||||||
logger.Error("------------- END Wox.Plugin.Program exception -------------");
|
logger.Error("------------- END Wox.Plugin.Program exception -------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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
|
||||||
|
/// </summary>
|
||||||
|
[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)
|
private static bool IsKnownWinProgramError(Exception e, string callingMethodName)
|
||||||
{
|
{
|
||||||
if (e.TargetSite?.Name == "GetDescription" && callingMethodName == "LnkProgram")
|
if (e.TargetSite?.Name == "GetDescription" && callingMethodName == "LnkProgram")
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
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);
|
+ $"unable to verify if package is valid", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user