From e45d4f60a44f39c4211db6ac1a8eebf0a26ff1b9 Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Thu, 5 Jan 2017 14:33:40 -0800 Subject: [PATCH] Moved Fatal logging to use nlog patterns --- .../ErrorManagement/NzbDroneErrorPipeline.cs | 16 +++++++--------- .../Instrumentation/GlobalExceptionHandlers.cs | 2 +- src/NzbDrone.Core/Tv/RefreshEpisodeService.cs | 4 ++-- src/NzbDrone.sln.DotSettings | 1 + src/NzbDrone/WindowsApp.cs | 5 ++--- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/NzbDrone.Api/ErrorManagement/NzbDroneErrorPipeline.cs b/src/NzbDrone.Api/ErrorManagement/NzbDroneErrorPipeline.cs index f65473cf0..d98925f8e 100644 --- a/src/NzbDrone.Api/ErrorManagement/NzbDroneErrorPipeline.cs +++ b/src/NzbDrone.Api/ErrorManagement/NzbDroneErrorPipeline.cs @@ -63,18 +63,16 @@ namespace NzbDrone.Api.ErrorManagement }.AsResponse(HttpStatusCode.Conflict); } - var sqlErrorMessage = string.Format("[{0} {1}]", context.Request.Method, context.Request.Path); - - _logger.Error(sqLiteException, sqlErrorMessage); + _logger.Error(sqLiteException, "[{0} {1}]", context.Request.Method, context.Request.Path); } - - _logger.Fatal(exception, "Request Failed"); + + _logger.Fatal(exception, "Request Failed. {0} {1}", context.Request.Method, context.Request.Path); return new ErrorModel - { - Message = exception.Message, - Description = exception.ToString() - }.AsResponse(HttpStatusCode.InternalServerError); + { + Message = exception.Message, + Description = exception.ToString() + }.AsResponse(HttpStatusCode.InternalServerError); } } } \ No newline at end of file diff --git a/src/NzbDrone.Common/Instrumentation/GlobalExceptionHandlers.cs b/src/NzbDrone.Common/Instrumentation/GlobalExceptionHandlers.cs index 05c5fe46c..b56c306a9 100644 --- a/src/NzbDrone.Common/Instrumentation/GlobalExceptionHandlers.cs +++ b/src/NzbDrone.Common/Instrumentation/GlobalExceptionHandlers.cs @@ -46,7 +46,7 @@ namespace NzbDrone.Common.Instrumentation } Console.WriteLine("EPIC FAIL: {0}", exception); - Logger.Fatal(exception, "EPIC FAIL: " + exception.Message); + Logger.Fatal(exception, "EPIC FAIL."); } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs b/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs index 7d1a7d993..5b4a07234 100644 --- a/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs +++ b/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs @@ -77,7 +77,7 @@ namespace NzbDrone.Core.Tv } catch (Exception e) { - _logger.Fatal(e, string.Format("An error has occurred while updating episode info for series {0}. {1}", series, episode)); + _logger.Fatal(e, "An error has occurred while updating episode info for series {0}. {1}", series, episode)); failCount++; } } @@ -126,7 +126,7 @@ namespace NzbDrone.Core.Tv } var groups = allEpisodes.Where(c => c.AirDateUtc.HasValue) - .GroupBy(e => new {e.SeasonNumber, e.AirDate}) + .GroupBy(e => new { e.SeasonNumber, e.AirDate }) .Where(g => g.Count() > 1) .ToList(); diff --git a/src/NzbDrone.sln.DotSettings b/src/NzbDrone.sln.DotSettings index 298cea9a9..260cae878 100644 --- a/src/NzbDrone.sln.DotSettings +++ b/src/NzbDrone.sln.DotSettings @@ -6,6 +6,7 @@ DO_NOT_SHOW ERROR ERROR + DO_NOT_SHOW ERROR HINT WARNING diff --git a/src/NzbDrone/WindowsApp.cs b/src/NzbDrone/WindowsApp.cs index b99f3d134..076c27a68 100644 --- a/src/NzbDrone/WindowsApp.cs +++ b/src/NzbDrone/WindowsApp.cs @@ -29,9 +29,8 @@ namespace NzbDrone } catch (Exception e) { - Logger.Fatal(e, "EPIC FAIL: " + e.Message); - var message = string.Format("{0}: {1}", e.GetType().Name, e.Message); - MessageBox.Show(text: message, buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error, caption: "Epic Fail!"); + Logger.Fatal(e, "EPIC FAIL"); + MessageBox.Show($"{e.GetType().Name}: {e.Message}", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error, caption: "Epic Fail!"); } } }