From 84b9db13f47ce7a60283654ee67b0b884e3cdd9b Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Mon, 17 Jul 2023 21:00:00 -0500 Subject: [PATCH] refactor: Print full exception stack trace to console Previously, the exception stack trace was omitted to simplify the console output. However, some situations occurred where an exception was logged but I couldn't tell where it came from. This made certain rare bugs impossible to fix. My philosophy at this point is: If something exceptional happens, we don't really care about a "clean" console output anymore... --- src/Recyclarr.Cli/Logging/LoggerFactory.cs | 4 +--- src/Recyclarr.Cli/Processors/Sync/SyncProcessor.cs | 2 -- src/Recyclarr.Cli/Program.cs | 10 ++++++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Recyclarr.Cli/Logging/LoggerFactory.cs b/src/Recyclarr.Cli/Logging/LoggerFactory.cs index 2dba064e..9108657e 100644 --- a/src/Recyclarr.Cli/Logging/LoggerFactory.cs +++ b/src/Recyclarr.Cli/Logging/LoggerFactory.cs @@ -31,9 +31,7 @@ public class LoggerFactory private static ExpressionTemplate GetConsoleTemplate() { - var template = "[{@l:u3}] " + GetBaseTemplateString() + - "{#if ExceptionMessage is not null}: {ExceptionMessage}{#end}" + - "\n"; + var template = "[{@l:u3}] " + GetBaseTemplateString() + "\n{@x}"; return new ExpressionTemplate(template, theme: TemplateTheme.Code); } diff --git a/src/Recyclarr.Cli/Processors/Sync/SyncProcessor.cs b/src/Recyclarr.Cli/Processors/Sync/SyncProcessor.cs index ff8f4f71..47502951 100644 --- a/src/Recyclarr.Cli/Processors/Sync/SyncProcessor.cs +++ b/src/Recyclarr.Cli/Processors/Sync/SyncProcessor.cs @@ -112,8 +112,6 @@ public class SyncProcessor : ISyncProcessor private void HandleException(Exception e) { - _log.Debug(e, "Sync Processor Exception"); - switch (e) { case GitCmdException e2: diff --git a/src/Recyclarr.Cli/Program.cs b/src/Recyclarr.Cli/Program.cs index 97b1aca6..6befa96c 100644 --- a/src/Recyclarr.Cli/Program.cs +++ b/src/Recyclarr.Cli/Program.cs @@ -53,8 +53,14 @@ internal static class Program } catch (Exception ex) { - AnsiConsole.WriteException(ex, ExceptionFormats.ShortenEverything); - _log?.Debug(ex, "Non-recoverable Exception"); + if (_log is null) + { + AnsiConsole.WriteException(ex, ExceptionFormats.ShortenEverything); + } + else + { + _log.Error(ex, "Non-recoverable Exception"); + } } finally {