mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
moved logging config to in-process
This commit is contained in:
parent
95b21358c4
commit
bceaee27a3
@ -6,6 +6,7 @@
|
||||
using NzbDrone.Api.ErrorManagement;
|
||||
using NzbDrone.Api.Extensions;
|
||||
using NzbDrone.Api.Extensions.Pipelines;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Instrumentation;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
@ -21,7 +22,7 @@ public class NancyBootstrapper : TinyIoCNancyBootstrapper
|
||||
public NancyBootstrapper(TinyIoCContainer tinyIoCContainer)
|
||||
{
|
||||
_tinyIoCContainer = tinyIoCContainer;
|
||||
_logger = LogManager.GetCurrentClassLogger();
|
||||
_logger = NzbDroneLogger.GetLogger();
|
||||
}
|
||||
|
||||
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
|
||||
|
@ -2,6 +2,7 @@
|
||||
using Microsoft.AspNet.SignalR;
|
||||
using Microsoft.AspNet.SignalR.Infrastructure;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Datastore.Events;
|
||||
@ -18,7 +19,7 @@ public abstract class BasicResourceConnection<T> :
|
||||
|
||||
public BasicResourceConnection()
|
||||
{
|
||||
_logger = LogManager.GetCurrentClassLogger();
|
||||
_logger = NzbDroneLogger.GetLogger(this);
|
||||
}
|
||||
|
||||
protected override Task OnConnected(IRequest request, string connectionId)
|
||||
|
@ -8,6 +8,7 @@
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnsureThat;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
@ -58,7 +59,7 @@ static extern bool GetDiskFreeSpaceEx(string lpDirectoryName,
|
||||
out ulong lpTotalNumberOfBytes,
|
||||
out ulong lpTotalNumberOfFreeBytes);
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
public HashSet<string> SpecialFolders
|
||||
{
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System.Security.AccessControl;
|
||||
using System.Security.Principal;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
|
||||
namespace NzbDrone.Common.EnvironmentInfo
|
||||
{
|
||||
@ -30,7 +31,7 @@ public AppFolderInfo(IDiskProvider diskProvider, IStartupArguments startupArgume
|
||||
DATA_SPECIAL_FOLDER = Environment.SpecialFolder.ApplicationData;
|
||||
}
|
||||
|
||||
_logger = LogManager.GetCurrentClassLogger();
|
||||
_logger = NzbDroneLogger.GetLogger(this);
|
||||
|
||||
if (startupArguments.Args.ContainsKey(StartupArguments.APPDATA))
|
||||
{
|
||||
|
@ -2,7 +2,6 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Security.Principal;
|
||||
using System.ServiceProcess;
|
||||
using NLog;
|
||||
|
||||
namespace NzbDrone.Common.EnvironmentInfo
|
||||
|
@ -17,14 +17,6 @@ public class StartupArguments : IStartupArguments
|
||||
public const string UNINSTALL_SERVICE = "u";
|
||||
public const string HELP = "?";
|
||||
|
||||
static StartupArguments()
|
||||
{
|
||||
if (RuntimeInfo.IsProduction)
|
||||
{
|
||||
Instance = new StartupArguments("");
|
||||
}
|
||||
}
|
||||
|
||||
public StartupArguments(params string[] args)
|
||||
{
|
||||
Flags = new HashSet<string>();
|
||||
@ -45,13 +37,9 @@ public StartupArguments(params string[] args)
|
||||
Flags.Add(flag);
|
||||
}
|
||||
}
|
||||
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public HashSet<string> Flags { get; private set; }
|
||||
public Dictionary<string, string> Args { get; private set; }
|
||||
|
||||
public static IStartupArguments Instance { get; private set; }
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NLog.LayoutRenderers;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
||||
namespace NzbDrone.Common.Instrumentation
|
||||
{
|
||||
[ThreadAgnostic]
|
||||
[LayoutRenderer("appLog")]
|
||||
public class ApplicationLogLayoutRenderer : LayoutRenderer
|
||||
{
|
||||
private readonly string _appData;
|
||||
|
||||
public ApplicationLogLayoutRenderer()
|
||||
{
|
||||
_appData = Path.Combine(new AppFolderInfo(new DiskProvider(), StartupArguments.Instance ).GetLogFolder(), "nzbdrone.txt");
|
||||
}
|
||||
|
||||
protected override void Append(StringBuilder builder, LogEventInfo logEvent)
|
||||
{
|
||||
builder.Append(_appData);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NLog.LayoutRenderers;
|
||||
|
||||
namespace NzbDrone.Common.Instrumentation
|
||||
{
|
||||
[ThreadAgnostic]
|
||||
[LayoutRenderer("dirSeparator")]
|
||||
public class DirSeparatorLayoutRenderer : LayoutRenderer
|
||||
{
|
||||
|
||||
protected override void Append(StringBuilder builder, LogEventInfo logEvent)
|
||||
{
|
||||
builder.Append(Path.DirectorySeparatorChar);
|
||||
}
|
||||
}
|
||||
}
|
@ -24,17 +24,7 @@ public class ExceptronTarget : Target
|
||||
public IExceptronClient ExceptronClient { get; internal set; }
|
||||
|
||||
|
||||
private static ExceptronTarget _instance = new ExceptronTarget();
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
var rule = new LoggingRule("*", LogLevel.Warn, _instance);
|
||||
|
||||
LogManager.Configuration.AddTarget("ExceptronTarget", _instance);
|
||||
LogManager.Configuration.LoggingRules.Add(rule);
|
||||
LogManager.ConfigurationReloaded += (sender, args) => Register();
|
||||
LogManager.ReconfigExistingLoggers();
|
||||
}
|
||||
|
||||
protected override void InitializeTarget()
|
||||
{
|
||||
|
@ -6,12 +6,9 @@ namespace NzbDrone.Common.Instrumentation
|
||||
{
|
||||
public static class GlobalExceptionHandlers
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetLogger("Global");
|
||||
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
|
||||
public static void Register()
|
||||
{
|
||||
ExceptronTarget.Register();
|
||||
|
||||
AppDomain.CurrentDomain.UnhandledException += ((s, e) => AppDomainException(e.ExceptionObject as Exception));
|
||||
TaskScheduler.UnobservedTaskException += ((s, e) => TaskException(e.Exception));
|
||||
}
|
||||
|
138
NzbDrone.Common/Instrumentation/LogTargets.cs
Normal file
138
NzbDrone.Common/Instrumentation/LogTargets.cs
Normal file
@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NLog.Targets;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
||||
namespace NzbDrone.Common.Instrumentation
|
||||
{
|
||||
public static class LogTargets
|
||||
{
|
||||
public static void Register(IStartupArguments startupArguments, bool updateApp, bool inConsole)
|
||||
{
|
||||
var appFolderInfo = new AppFolderInfo(new DiskProvider(), startupArguments);
|
||||
|
||||
LogManager.Configuration = new LoggingConfiguration();
|
||||
|
||||
RegisterExceptron();
|
||||
|
||||
if (updateApp)
|
||||
{
|
||||
RegisterLoggly();
|
||||
RegisterUpdateFile(appFolderInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inConsole && (OsInfo.IsLinux || new RuntimeInfo(null).IsUserInteractive))
|
||||
{
|
||||
RegisterConsole();
|
||||
}
|
||||
|
||||
RegisterAppFile(appFolderInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private static void RegisterConsole()
|
||||
{
|
||||
var level = LogLevel.Trace;
|
||||
|
||||
if (RuntimeInfo.IsProduction)
|
||||
{
|
||||
level = LogLevel.Info;
|
||||
}
|
||||
|
||||
var coloredConsoleTarget = new ColoredConsoleTarget();
|
||||
|
||||
coloredConsoleTarget.Name = "consoleLogger";
|
||||
coloredConsoleTarget.Layout = "[${level}] ${logger}: ${message} ${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}";
|
||||
|
||||
var loggingRule = new LoggingRule("*", level, coloredConsoleTarget);
|
||||
|
||||
LogManager.Configuration.AddTarget("console", coloredConsoleTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(loggingRule);
|
||||
|
||||
LogManager.ConfigurationReloaded += (sender, args) => RegisterConsole();
|
||||
LogManager.ReconfigExistingLoggers();
|
||||
}
|
||||
|
||||
|
||||
const string FileLogLayout = @"${date:format=yy-M-d HH\:mm\:ss.f}|${level}|${logger}|${message}${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}";
|
||||
|
||||
private static void RegisterAppFile(IAppFolderInfo appFolderInfo)
|
||||
{
|
||||
var fileTarget = new FileTarget();
|
||||
|
||||
fileTarget.Name = "rollingFileLogger";
|
||||
fileTarget.FileName = Path.Combine(appFolderInfo.GetLogFolder(), "nzbdrone.txt");
|
||||
fileTarget.AutoFlush = true;
|
||||
fileTarget.KeepFileOpen = false;
|
||||
fileTarget.ConcurrentWrites = false;
|
||||
fileTarget.ConcurrentWriteAttemptDelay = 50;
|
||||
fileTarget.ConcurrentWriteAttempts = 10;
|
||||
fileTarget.ArchiveAboveSize = 1024000;
|
||||
fileTarget.MaxArchiveFiles = 5;
|
||||
fileTarget.EnableFileDelete = true;
|
||||
fileTarget.ArchiveNumbering = ArchiveNumberingMode.Rolling;
|
||||
fileTarget.Layout = FileLogLayout;
|
||||
|
||||
var loggingRule = new LoggingRule("*", LogLevel.Info, fileTarget);
|
||||
|
||||
LogManager.Configuration.AddTarget("appfile", fileTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(loggingRule);
|
||||
|
||||
LogManager.ConfigurationReloaded += (sender, args) => RegisterAppFile(appFolderInfo);
|
||||
LogManager.ReconfigExistingLoggers();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void RegisterUpdateFile(IAppFolderInfo appFolderInfo)
|
||||
{
|
||||
var fileTarget = new FileTarget();
|
||||
|
||||
fileTarget.Name = "updateFileLogger";
|
||||
fileTarget.FileName = Path.Combine(appFolderInfo.GetUpdateLogFolder(), DateTime.Now.ToString("yy.MM.d-HH.mm") + ".txt");
|
||||
fileTarget.AutoFlush = true;
|
||||
fileTarget.KeepFileOpen = false;
|
||||
fileTarget.ConcurrentWrites = false;
|
||||
fileTarget.ConcurrentWriteAttemptDelay = 50;
|
||||
fileTarget.ConcurrentWriteAttempts = 100;
|
||||
fileTarget.Layout = FileLogLayout;
|
||||
|
||||
var loggingRule = new LoggingRule("*", LogLevel.Trace, fileTarget);
|
||||
|
||||
LogManager.Configuration.AddTarget("updateFile", fileTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(loggingRule);
|
||||
|
||||
LogManager.ConfigurationReloaded += (sender, args) => RegisterUpdateFile(appFolderInfo);
|
||||
LogManager.ReconfigExistingLoggers();
|
||||
}
|
||||
|
||||
private static void RegisterExceptron()
|
||||
{
|
||||
|
||||
var exceptronTarget = new ExceptronTarget();
|
||||
var rule = new LoggingRule("*", LogLevel.Warn, exceptronTarget);
|
||||
|
||||
LogManager.Configuration.AddTarget("ExceptronTarget", exceptronTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(rule);
|
||||
LogManager.ConfigurationReloaded += (sender, args) => RegisterExceptron();
|
||||
LogManager.ReconfigExistingLoggers();
|
||||
}
|
||||
|
||||
|
||||
public static void RegisterLoggly()
|
||||
{
|
||||
var logglyTarger = new LogglyTarget();
|
||||
|
||||
var rule = new LoggingRule("*", LogLevel.Trace, logglyTarger);
|
||||
|
||||
LogManager.Configuration.AddTarget("LogglyLogger", logglyTarger);
|
||||
LogManager.Configuration.LoggingRules.Add(rule);
|
||||
LogManager.ConfigurationReloaded += (sender, args) => RegisterLoggly();
|
||||
LogManager.ReconfigExistingLoggers();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NLog.Layouts;
|
||||
using NLog.Targets;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
@ -13,16 +12,10 @@ public class LogglyTarget : TargetWithLayout
|
||||
{
|
||||
private Logger _logger;
|
||||
|
||||
public void Register(LogLevel minLevel)
|
||||
public LogglyTarget()
|
||||
{
|
||||
Layout = new SimpleLayout("${callsite:className=false:fileName=false:includeSourcePath=false:methodName=true}");
|
||||
|
||||
var rule = new LoggingRule("*", minLevel, this);
|
||||
|
||||
LogManager.Configuration.AddTarget("LogglyLogger", this);
|
||||
LogManager.Configuration.LoggingRules.Add(rule);
|
||||
LogManager.ConfigurationReloaded += (sender, args) => Register(minLevel);
|
||||
LogManager.ReconfigExistingLoggers();
|
||||
|
||||
}
|
||||
|
||||
protected override void InitializeTarget()
|
||||
|
42
NzbDrone.Common/Instrumentation/NzbDroneLogger.cs
Normal file
42
NzbDrone.Common/Instrumentation/NzbDroneLogger.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using NLog;
|
||||
|
||||
namespace NzbDrone.Common.Instrumentation
|
||||
{
|
||||
public static class NzbDroneLogger
|
||||
{
|
||||
public static Logger GetLogger()
|
||||
{
|
||||
string loggerName;
|
||||
Type declaringType;
|
||||
int framesToSkip = 1;
|
||||
do
|
||||
{
|
||||
var frame = new StackFrame(framesToSkip, false);
|
||||
var method = frame.GetMethod();
|
||||
declaringType = method.DeclaringType;
|
||||
if (declaringType == null)
|
||||
{
|
||||
loggerName = method.Name;
|
||||
break;
|
||||
}
|
||||
|
||||
framesToSkip++;
|
||||
loggerName = declaringType.Name;
|
||||
} while (declaringType.Module.Name.Equals("mscorlib.dll", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
return LogManager.GetLogger(loggerName);
|
||||
}
|
||||
|
||||
public static Logger GetLogger(object obj)
|
||||
{
|
||||
return LogManager.GetLogger(obj.GetType().Name);
|
||||
}
|
||||
|
||||
public static Logger GetLogger<T>()
|
||||
{
|
||||
return LogManager.GetLogger(typeof(T).Name);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NLog.LayoutRenderers;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
||||
namespace NzbDrone.Common.Instrumentation
|
||||
{
|
||||
[ThreadAgnostic]
|
||||
[LayoutRenderer("updateLog")]
|
||||
public class UpdateLogLayoutRenderer : LayoutRenderer
|
||||
{
|
||||
private readonly string _appData;
|
||||
|
||||
public UpdateLogLayoutRenderer()
|
||||
{
|
||||
_appData = Path.Combine(new AppFolderInfo(new DiskProvider(), StartupArguments.Instance).GetUpdateLogFolder(), DateTime.Now.ToString("yy.MM.d-HH.mm") + ".txt");
|
||||
|
||||
}
|
||||
|
||||
protected override void Append(StringBuilder builder, LogEventInfo logEvent)
|
||||
{
|
||||
builder.Append(_appData);
|
||||
}
|
||||
}
|
||||
}
|
@ -92,6 +92,8 @@
|
||||
<Compile Include="IEnumerableExtensions.cs" />
|
||||
<Compile Include="Instrumentation\GlobalExceptionHandlers.cs" />
|
||||
<Compile Include="Instrumentation\ExceptronTarget.cs" />
|
||||
<Compile Include="Instrumentation\NzbDroneLogger.cs" />
|
||||
<Compile Include="Instrumentation\LogTargets.cs" />
|
||||
<Compile Include="PathEqualityComparer.cs" />
|
||||
<Compile Include="Services.cs" />
|
||||
<Compile Include="TPL\LimitedConcurrencyLevelTaskScheduler.cs" />
|
||||
@ -99,11 +101,8 @@
|
||||
<Compile Include="StringExtensions.cs" />
|
||||
<Compile Include="EnsureThat\TypeParam.cs" />
|
||||
<Compile Include="HashUtil.cs" />
|
||||
<Compile Include="Instrumentation\ApplicationLogLayoutRenderer.cs" />
|
||||
<Compile Include="Instrumentation\DirSeparatorLayoutRenderer.cs" />
|
||||
<Compile Include="Instrumentation\LogEventExtensions.cs" />
|
||||
<Compile Include="Instrumentation\LogglyTarget.cs" />
|
||||
<Compile Include="Instrumentation\UpdateLogLayoutRenderer.cs" />
|
||||
<Compile Include="Serializer\Json.cs" />
|
||||
<Compile Include="Messaging\CommandCompletedEvent.cs" />
|
||||
<Compile Include="Messaging\CommandStartedEvent.cs" />
|
||||
|
@ -6,6 +6,7 @@
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Common.Model;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
@ -26,7 +27,7 @@ public interface IProcessProvider
|
||||
|
||||
public class ProcessProvider : IProcessProvider
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
public const string NZB_DRONE_PROCESS_NAME = "NzbDrone";
|
||||
public const string NZB_DRONE_CONSOLE_PROCESS_NAME = "NzbDrone.Console";
|
||||
|
@ -3,12 +3,13 @@
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
|
||||
namespace NzbDrone.Common.Security
|
||||
{
|
||||
public static class IgnoreCertErrorPolicy
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetLogger("CertPolicy");
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
|
@ -5,6 +5,7 @@
|
||||
using System.Linq;
|
||||
using System.ServiceProcess;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
@ -25,7 +26,7 @@ public class ServiceProvider : IServiceProvider
|
||||
{
|
||||
public const string NZBDRONE_SERVICE_NAME = "NzbDrone";
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
public virtual bool ServiceExist(string name)
|
||||
{
|
||||
|
@ -1,11 +1,12 @@
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
|
||||
namespace NzbDrone.Common.TPL
|
||||
{
|
||||
public static class TaskExtensions
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetLogger("TaskExtensions");
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
public static Task LogExceptions(this Task task)
|
||||
{
|
||||
|
@ -2,17 +2,22 @@
|
||||
using System.Threading;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Host;
|
||||
|
||||
namespace NzbDrone.Console
|
||||
{
|
||||
public static class ConsoleApp
|
||||
{
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
Bootstrap.Start(new StartupArguments(args), new ConsoleAlerts());
|
||||
var startupArgs = new StartupArguments(args);
|
||||
LogTargets.Register(startupArgs, false, true);
|
||||
Bootstrap.Start(startupArgs, new ConsoleAlerts());
|
||||
}
|
||||
catch (TerminateApplicationException)
|
||||
{
|
||||
@ -28,4 +33,4 @@ public static void Main(string[] args)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
using FluentAssertions;
|
||||
using NLog;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Instrumentation;
|
||||
@ -36,8 +37,7 @@ public void Setup()
|
||||
LogManager.ReconfigExistingLoggers();
|
||||
|
||||
|
||||
_logger = LogManager.GetCurrentClassLogger();
|
||||
_loggerName = _logger.Name.Replace("NzbDrone.","");
|
||||
_logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
_uniqueMessage = "Unique message: " + Guid.NewGuid().ToString();
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
using System.IO;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
@ -15,7 +16,7 @@ public class PneumaticClient : IDownloadClient
|
||||
private readonly IHttpProvider _httpProvider;
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Logger logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
public PneumaticClient(IConfigService configService, IHttpProvider httpProvider,
|
||||
IDiskProvider diskProvider)
|
||||
|
@ -6,12 +6,13 @@
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text.RegularExpressions;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||
{
|
||||
public class SabAutoConfigureService
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
public SabModel AutoConfigureSab()
|
||||
{
|
||||
|
@ -7,6 +7,7 @@
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.Indexers
|
||||
@ -22,7 +23,7 @@ public class BasicRssParser : IParseFeed
|
||||
|
||||
public BasicRssParser()
|
||||
{
|
||||
_logger = LogManager.GetCurrentClassLogger();
|
||||
_logger = NzbDroneLogger.GetLogger(this);
|
||||
}
|
||||
|
||||
public IEnumerable<ReportInfo> Process(string xml, string url)
|
||||
|
@ -3,6 +3,7 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.NzbClub
|
||||
@ -15,7 +16,7 @@ public class NzbClubParser : BasicRssParser
|
||||
|
||||
public NzbClubParser()
|
||||
{
|
||||
logger = LogManager.GetCurrentClassLogger();
|
||||
logger = NzbDroneLogger.GetLogger();
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,13 +5,14 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
|
||||
namespace NzbDrone.Core.Indexers
|
||||
{
|
||||
public static class XElementExtensions
|
||||
{
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
private static readonly Regex RemoveTimeZoneRegex = new Regex(@"\s[A-Z]{2,4}$", RegexOptions.Compiled);
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MediaFiles.Commands;
|
||||
@ -23,7 +24,7 @@ public class RecycleBinProvider : IHandleAsync<SeriesDeletedEvent>, IExecute<Cle
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
private readonly IConfigService _configService;
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Logger logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
public RecycleBinProvider(IDiskProvider diskProvider, IConfigService configService)
|
||||
{
|
||||
|
@ -3,6 +3,7 @@
|
||||
using System.Linq;
|
||||
using Growl.Connector;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Common.Messaging;
|
||||
using GrowlNotification = Growl.Connector.Notification;
|
||||
|
||||
@ -15,7 +16,7 @@ public interface IGrowlService
|
||||
|
||||
public class GrowlService : IGrowlService, IExecute<TestGrowlCommand>
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
private readonly Application _growlApplication = new Application("NzbDrone");
|
||||
private GrowlConnector _growlConnector;
|
||||
|
@ -5,6 +5,7 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model.Xbmc;
|
||||
@ -21,7 +22,7 @@ public interface IXbmcService
|
||||
|
||||
public class XbmcService : IXbmcService, IExecute<TestXbmcCommand>
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
|
||||
private readonly IHttpProvider _httpProvider;
|
||||
private readonly IEnumerable<IApiProvider> _apiProviders;
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
@ -13,7 +14,7 @@ namespace NzbDrone.Core.Parser
|
||||
{
|
||||
public static class Parser
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
private static readonly Regex[] ReportTitleRegex = new[]
|
||||
{
|
||||
|
@ -5,6 +5,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Core.Model.Xem;
|
||||
|
||||
namespace NzbDrone.Core.Providers
|
||||
@ -20,7 +21,7 @@ public class XemCommunicationProvider : IXemCommunicationProvider
|
||||
{
|
||||
private readonly IHttpProvider _httpProvider;
|
||||
|
||||
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Logger _logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
private const string XEM_BASE_URL = "http://thexem.de/map/";
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Cache;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
using NzbDrone.Core.Tv;
|
||||
@ -25,7 +26,7 @@ public class XemProvider : IXemProvider, IExecute<UpdateXemMappingsCommand>, IHa
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly ICached<bool> _cache;
|
||||
|
||||
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Logger _logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
public XemProvider(IEpisodeService episodeService,
|
||||
IXemCommunicationProvider xemCommunicationProvider,
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Net;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnsureThat;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using RestSharp;
|
||||
|
||||
@ -8,7 +9,7 @@ namespace NzbDrone.Core.Rest
|
||||
{
|
||||
public static class RestSharpExtensions
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetLogger("RestExtensions");
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
public static IRestResponse ValidateResponse(this IRestResponse response, IRestClient restClient)
|
||||
{
|
||||
@ -22,7 +23,7 @@ public static IRestResponse ValidateResponse(this IRestResponse response, IRestC
|
||||
Ensure.That(() => response.Request).IsNotNull();
|
||||
Ensure.That(() => restClient).IsNotNull();
|
||||
|
||||
Logger.Trace("Validating Responses from [{0}] [{1}] status: [{2}] body:[{3}]", response.Request.Method, restClient.BuildUri(response.Request), response.StatusCode, response.Content);
|
||||
Logger.Trace("Validating Responses from [{0}] [{1}] status: [{2}]", response.Request.Method, restClient.BuildUri(response.Request), response.StatusCode);
|
||||
|
||||
if (response.ResponseUri == null)
|
||||
{
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System.IO;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Tv;
|
||||
@ -23,7 +24,7 @@ public interface IRootFolderService
|
||||
|
||||
public class RootFolderService : IRootFolderService
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
|
||||
private readonly IBasicRepository<RootFolder> _rootFolderRepository;
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Datastore;
|
||||
@ -40,7 +41,7 @@ public class EpisodeService : IEpisodeService,
|
||||
IHandleAsync<SeriesDeletedEvent>
|
||||
{
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Logger logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
private readonly IEpisodeRepository _episodeRepository;
|
||||
private readonly IConfigService _configService;
|
||||
|
@ -12,7 +12,7 @@ public static class Bootstrap
|
||||
{
|
||||
public static IContainer Start(StartupArguments args, IUserAlert userAlert)
|
||||
{
|
||||
var logger = LogManager.GetLogger("AppMain");
|
||||
var logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
GlobalExceptionHandlers.Register();
|
||||
IgnoreCertErrorPolicy.Register();
|
||||
|
@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
autoReload="true"
|
||||
internalLogLevel="Info"
|
||||
throwExceptions="true"
|
||||
internalLogToConsole="true"
|
||||
internalLogToConsoleError="true">
|
||||
<extensions>
|
||||
<add assembly="NzbDrone.Core"/>
|
||||
<add assembly="NzbDrone.Common"/>
|
||||
</extensions>
|
||||
<targets>
|
||||
<target xsi:type="ColoredConsole" name="consoleLogger" layout="[${level}] ${logger}: ${message} ${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}"/>
|
||||
<target xsi:type="NLogViewer" name="udpTarget" address="udp://127.0.0.1:20480" includeCallSite="true" includeSourceInfo="true" includeNLogData="true" includeNdc="true">
|
||||
<parameter>
|
||||
<name>Exception</name>
|
||||
<layout>${exception:format=ToString}</layout>
|
||||
</parameter>
|
||||
</target>
|
||||
<target xsi:type="File" name="rollingFileLogger" fileName="${appLog}" autoFlush="true" keepFileOpen="false"
|
||||
concurrentWrites="false" concurrentWriteAttemptDelay="50" concurrentWriteAttempts ="10"
|
||||
archiveAboveSize="1024000" maxArchiveFiles="5" enableFileDelete="true" archiveNumbering ="Rolling"
|
||||
layout="${date:format=yy-M-d HH\:mm\:ss.f}|${level}|${logger}|${message}${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}"/>
|
||||
</targets>
|
||||
<rules>
|
||||
<logger name="*" minlevel="Trace" writeTo="consoleLogger"/>
|
||||
<logger name="*" minlevel="Off" writeTo="udpTarget"/>
|
||||
<logger name="*" minlevel="Info" writeTo="rollingFileLogger"/>
|
||||
</rules>
|
||||
</nlog>
|
@ -141,10 +141,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<Content Include="NLog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<None Include="NLog.xsd">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
|
@ -1,12 +1,13 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
|
||||
namespace NzbDrone.Host.Owin
|
||||
{
|
||||
public class NlogTextWriter : TextWriter
|
||||
{
|
||||
private readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly Logger logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
|
||||
public override Encoding Encoding
|
||||
|
@ -3,12 +3,13 @@
|
||||
using System.Reflection;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
|
||||
namespace NzbDrone.Host
|
||||
{
|
||||
public static class PlatformValidation
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
public static bool IsValidate(IUserAlert userAlert)
|
||||
{
|
||||
|
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<extensions>
|
||||
<add assembly="NzbDrone.Common"/>
|
||||
</extensions>
|
||||
<targets>
|
||||
<target xsi:type="ColoredConsole" name="consoleLogger" layout="[${level}] ${logger}: ${message} ${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}"/>
|
||||
<target xsi:type="File" name="fileLogger" fileName="${updateLog}" autoFlush="true" keepFileOpen="false"
|
||||
concurrentWrites="false" concurrentWriteAttemptDelay="50" concurrentWriteAttempts ="10"
|
||||
layout="${date:format=yy-M-d HH\:mm\:ss.f}|${level}|${logger}|${message}${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}"/>
|
||||
</targets>
|
||||
<rules>
|
||||
<logger name="*" minlevel="Debug" writeTo="consoleLogger"/>
|
||||
<logger name="*" minlevel="Trace" writeTo="fileLogger"/>
|
||||
</rules>
|
||||
</nlog>
|
@ -63,10 +63,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<Content Include="NLog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<None Include="NLog.xsd">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
|
@ -16,7 +16,7 @@ public class UpdateApp
|
||||
private readonly IProcessProvider _processProvider;
|
||||
private static IContainer _container;
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Logger logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
public UpdateApp(IInstallUpdateService installUpdateService, IProcessProvider processProvider)
|
||||
{
|
||||
@ -28,14 +28,16 @@ public static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
var startupArgument = new StartupArguments(args);
|
||||
LogTargets.Register(startupArgument, true, true);
|
||||
|
||||
Console.WriteLine("Starting NzbDrone Update Client");
|
||||
|
||||
IgnoreCertErrorPolicy.Register();
|
||||
|
||||
GlobalExceptionHandlers.Register();
|
||||
|
||||
new LogglyTarget().Register(LogLevel.Trace);
|
||||
_container = UpdateContainerBuilder.Build(new StartupArguments(args));
|
||||
_container = UpdateContainerBuilder.Build(startupArgument);
|
||||
|
||||
logger.Info("Updating NzbDrone to version {0}", BuildInfo.Version);
|
||||
_container.Resolve<UpdateApp>().Start(args);
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Windows.Forms;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Host;
|
||||
using NzbDrone.SysTray;
|
||||
|
||||
@ -9,12 +10,17 @@ namespace NzbDrone
|
||||
{
|
||||
public static class WindowsApp
|
||||
{
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
var container = Bootstrap.Start(new StartupArguments(args), new MessageBoxUserAlert());
|
||||
var startupArgs = new StartupArguments(args);
|
||||
|
||||
LogTargets.Register(startupArgs, false, true);
|
||||
|
||||
var container = Bootstrap.Start(startupArgs, new MessageBoxUserAlert());
|
||||
container.Register<ISystemTrayApp, SystemTrayApp>();
|
||||
container.Resolve<ISystemTrayApp>().Start();
|
||||
}
|
||||
@ -28,4 +34,4 @@ public static void Main(string[] args)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user