microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
111.33k stars 6.55k forks source link

Fix Faulty Exception Logs #6253

Closed ryanbodrug-microsoft closed 4 years ago

ryanbodrug-microsoft commented 4 years ago

Remove hard to use overload of Log.Exception

What is the expected behavior of the proposed feature? What is the scenario this would be used?

Wox.Infrastructure.Log provides two overloads of Exception for logiging.

1. public static void Exception(string className, string message, System.Exception exception, [CallerMemberName] string methodName = "")

2. public static void Exception(string message, System.Exception e)

The second overload is problematic in that it enforces a specific format at runtime and logs the following if the message string doesn't conform to the expected pipe (|) delimited parameters:

2020-08-27 09:51:31.8158|ERROR||------------- END Microsoft.Plugin.Program exception ------------- 2020-08-27 09:51:36.4334|FATAL|FaultyLogger|Wrong logger message format <|JsonStorage.TryLoad|Deleting cached data|<C:\Users*\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\Plugins\Microsoft.Plugin.Shell\Settings.json>> 2020-08-27 09:51:36.4497|FATAL|FaultyLogger|Wrong logger message format <|JsonStorage.Save|Saving cached data| <C:\Users*\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\Plugins\Microsoft.Plugin.Shell\Settings.json>> 2020-08-27 09:51:36.5306|FATAL|FaultyLogger|Wrong logger message format <|JsonStorage.Save|Saving cached data| <C:\Users*\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\QueryHistory.json>> 2020-08-27 09:51:36.5306|FATAL|FaultyLogger|Wrong logger message format <|JsonStorage.TryLoad|Deleting cached data|<C:\Users*\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\UserSelectedRecord.json>> 2020-08-27 09:51:36.5306|FATAL|FaultyLogger|Wrong logger message format <|JsonStorage.Save|Saving cached data| <C:\Users*\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\UserSelectedRecord.json>> 2020-08-27 09:51:36.5512|FATAL|FaultyLogger|Wrong logger message format <|JsonStorage.TryLoad|Deleting cached data|<C:\Users*\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\TopMostRecord.json>> 2020-08-27 09:51:36.5512|FATAL|FaultyLogger|Wrong logger message format <|JsonStorage.Save|Saving cached data| <C:\Users*\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\TopMostRecord.json>> 2020-08-27 09:51:36.7202|FATAL|FaultyLogger|Wrong logger message format <|JsonStorage.TryLoad|Deleting cached data|<C:\Users*\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\Plugins\Microsoft.Plugin.Indexer\Settings.json>> 2020-08-27 09:51:36.7202|FATAL|FaultyLogger|Wrong logger message format <|JsonStorage.Save|Saving cached data| <C:\Users***\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\Plugins\Microsoft.Plugin.Indexer\Settings.json>> I will try it as soon as 0.21 is released as well.

FIX: We should remove the overload that takes message, string, so that the expected format can be enforced at compile time.

If you'd like to see this feature implemented, add a 👍 reaction to this post.

ryanbodrug-microsoft commented 4 years ago

@saahmedm / @crutkas FYI:

crutkas commented 4 years ago

love this. I think this is a task i can handle so your team can do higher pri items

crutkas commented 4 years ago

Fixed in 0.23 of PowerToys. https://github.com/microsoft/PowerToys/releases/