|
|
@ -1,13 +1,14 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using NLog.Config;
|
|
|
|
using NLog.Config;
|
|
|
|
using NLog;
|
|
|
|
using NLog;
|
|
|
|
|
|
|
|
using NLog.Layouts;
|
|
|
|
using NLog.Targets;
|
|
|
|
using NLog.Targets;
|
|
|
|
using NzbDrone.Common;
|
|
|
|
using NzbDrone.Common;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Instrumentation
|
|
|
|
namespace NzbDrone.Core.Instrumentation
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public class DatabaseTarget : Target
|
|
|
|
public class DatabaseTarget : TargetWithLayout
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly ILogRepository _repository;
|
|
|
|
private readonly ILogRepository _repository;
|
|
|
|
|
|
|
|
|
|
|
@ -18,9 +19,10 @@ namespace NzbDrone.Core.Instrumentation
|
|
|
|
|
|
|
|
|
|
|
|
public void Register()
|
|
|
|
public void Register()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Layout = new SimpleLayout("${callsite:className=false:fileName=false:includeSourcePath=false:methodName=true}");
|
|
|
|
|
|
|
|
|
|
|
|
LogManager.Configuration.AddTarget("DbLogger", this);
|
|
|
|
LogManager.Configuration.AddTarget("DbLogger", this);
|
|
|
|
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, this));
|
|
|
|
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, this));
|
|
|
|
|
|
|
|
|
|
|
|
LogManager.ConfigurationReloaded += (sender, args) => Register();
|
|
|
|
LogManager.ConfigurationReloaded += (sender, args) => Register();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -30,11 +32,7 @@ namespace NzbDrone.Core.Instrumentation
|
|
|
|
var log = new Log();
|
|
|
|
var log = new Log();
|
|
|
|
log.Time = logEvent.TimeStamp;
|
|
|
|
log.Time = logEvent.TimeStamp;
|
|
|
|
log.Message = logEvent.FormattedMessage;
|
|
|
|
log.Message = logEvent.FormattedMessage;
|
|
|
|
|
|
|
|
log.Method = Layout.Render(logEvent);
|
|
|
|
if (logEvent.UserStackFrame != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log.Method = logEvent.UserStackFrame.GetMethod().Name;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.Logger = logEvent.LoggerName;
|
|
|
|
log.Logger = logEvent.LoggerName;
|
|
|
|
|
|
|
|
|
|
|
|