From 254561aeb1e14a832ca223b09fd7f188eb258710 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 21 Sep 2019 14:54:13 -0400 Subject: [PATCH] Fixed: Register Null Target for Sentry logs in Tests --- .../MediaFiles/MediaInfo/MediaInfoFormatter.cs | 1 - src/NzbDrone.Test.Common/LoggingTest.cs | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs b/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs index f25f2b9bc..6ced34684 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs @@ -1,6 +1,5 @@ using System; using System.Globalization; -using System.IO; using System.Linq; using System.Text.RegularExpressions; using NLog; diff --git a/src/NzbDrone.Test.Common/LoggingTest.cs b/src/NzbDrone.Test.Common/LoggingTest.cs index 3b673390b..45f666c09 100644 --- a/src/NzbDrone.Test.Common/LoggingTest.cs +++ b/src/NzbDrone.Test.Common/LoggingTest.cs @@ -26,6 +26,8 @@ protected static void InitLogging() var logOutput = TestLogOutput.Console; Enum.TryParse(Environment.GetEnvironmentVariable("RADARR_TESTS_LOG_OUTPUT"), out logOutput); + RegisterSentryLogger(); + switch (logOutput) { case TestLogOutput.Console: @@ -68,6 +70,13 @@ private static void RegisterFileLogger() LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, fileTarget)); } + private static void RegisterSentryLogger() + { + // Register a null target for sentry logs, so they aren't caught by other loggers. + var loggingRuleSentry = new LoggingRule("Sentry", LogLevel.Debug, new NullTarget()) { Final = true }; + LogManager.Configuration.LoggingRules.Insert(0, loggingRuleSentry); + } + private static void RegisterExceptionVerification() { var exceptionVerification = new ExceptionVerification();