From ff5dc6f0ce3f2dc05541ad1440e7e0f8a90dbf64 Mon Sep 17 00:00:00 2001 From: Icer Addis Date: Thu, 2 Jan 2014 19:43:57 -0800 Subject: [PATCH 1/4] NLog - Added debugger target --- .../Instrumentation/LogTargets.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/NzbDrone.Common/Instrumentation/LogTargets.cs b/src/NzbDrone.Common/Instrumentation/LogTargets.cs index 4f028aa60..e5d1be2f0 100644 --- a/src/NzbDrone.Common/Instrumentation/LogTargets.cs +++ b/src/NzbDrone.Common/Instrumentation/LogTargets.cs @@ -15,6 +15,11 @@ namespace NzbDrone.Common.Instrumentation LogManager.Configuration = new LoggingConfiguration(); + if (System.Diagnostics.Debugger.IsAttached) + { + RegisterDebugger(); + } + RegisterExceptron(); if (updateApp) @@ -35,6 +40,18 @@ namespace NzbDrone.Common.Instrumentation LogManager.ReconfigExistingLoggers(); } + private static void RegisterDebugger() + { + DebuggerTarget target = new DebuggerTarget(); + target.Name = "debuggerLogger"; + target.Layout = "[${level}] [${threadid}] ${logger}: ${message} ${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}"; + + var loggingRule = new LoggingRule("*", LogLevel.Trace, target); + LogManager.Configuration.AddTarget("console", target); + LogManager.Configuration.LoggingRules.Add(loggingRule); + } + + private static void RegisterConsole() { var level = LogLevel.Trace; From 6c34acc8b323d407bc115ad1c1fb377b5049dbec Mon Sep 17 00:00:00 2001 From: Icer Addis Date: Thu, 2 Jan 2014 19:47:21 -0800 Subject: [PATCH 2/4] NLog - fixed debugger target name --- src/NzbDrone.Common/Instrumentation/LogTargets.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NzbDrone.Common/Instrumentation/LogTargets.cs b/src/NzbDrone.Common/Instrumentation/LogTargets.cs index e5d1be2f0..6f35a8a95 100644 --- a/src/NzbDrone.Common/Instrumentation/LogTargets.cs +++ b/src/NzbDrone.Common/Instrumentation/LogTargets.cs @@ -47,7 +47,7 @@ namespace NzbDrone.Common.Instrumentation target.Layout = "[${level}] [${threadid}] ${logger}: ${message} ${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}"; var loggingRule = new LoggingRule("*", LogLevel.Trace, target); - LogManager.Configuration.AddTarget("console", target); + LogManager.Configuration.AddTarget("debugger", target); LogManager.Configuration.LoggingRules.Add(loggingRule); } From e2939847a5af292cad82d9565a9915f1a51dacd6 Mon Sep 17 00:00:00 2001 From: Icer Addis Date: Tue, 7 Jan 2014 04:12:55 -0800 Subject: [PATCH 3/4] Parser logging - changed Debug.WriteLine to Logger.Trace --- src/NzbDrone.Core/Parser/Parser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index 7797a61cd..21d88b971 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -153,7 +153,7 @@ namespace NzbDrone.Core.Parser if (match.Count != 0) { - Debug.WriteLine(regex); + Logger.Trace(regex); try { var result = ParseMatchCollection(match); From 11aa82832f9abd10650fa8d48632a7c60bb7214b Mon Sep 17 00:00:00 2001 From: Icer Addis Date: Mon, 13 Jan 2014 21:25:03 -0800 Subject: [PATCH 4/4] Added using statement --- src/NzbDrone.Common/Instrumentation/LogTargets.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Common/Instrumentation/LogTargets.cs b/src/NzbDrone.Common/Instrumentation/LogTargets.cs index 6f35a8a95..ec21d2b5c 100644 --- a/src/NzbDrone.Common/Instrumentation/LogTargets.cs +++ b/src/NzbDrone.Common/Instrumentation/LogTargets.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.IO; using NLog; using NLog.Config; @@ -15,7 +16,7 @@ namespace NzbDrone.Common.Instrumentation LogManager.Configuration = new LoggingConfiguration(); - if (System.Diagnostics.Debugger.IsAttached) + if (Debugger.IsAttached) { RegisterDebugger(); }