mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 13:33:34 -07:00
Renamed SubsonicTarget to DataBaseTarget
This commit is contained in:
parent
5acfce2cc7
commit
7d706a3304
6 changed files with 10 additions and 10 deletions
57
NzbDrone.Core/Instrumentation/DatabaseTarget.cs
Normal file
57
NzbDrone.Core/Instrumentation/DatabaseTarget.cs
Normal file
|
@ -0,0 +1,57 @@
|
|||
using System;
|
||||
using NLog;
|
||||
using NLog.Targets;
|
||||
using NLog.Targets.Wrappers;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Instrumentation
|
||||
{
|
||||
|
||||
public class DatabaseTarget : Target
|
||||
{
|
||||
private readonly IDatabase _database;
|
||||
|
||||
public DatabaseTarget(IDatabase database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected override void Write(LogEventInfo logEvent)
|
||||
{
|
||||
var log = new Log();
|
||||
log.Time = logEvent.TimeStamp;
|
||||
log.Message = logEvent.FormattedMessage;
|
||||
|
||||
if (logEvent.UserStackFrame != null)
|
||||
{
|
||||
log.Method = logEvent.UserStackFrame.GetMethod().Name;
|
||||
}
|
||||
|
||||
log.Logger = logEvent.LoggerName;
|
||||
|
||||
if (logEvent.Exception != null)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(log.Message))
|
||||
{
|
||||
log.Message = logEvent.Exception.Message;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.Message += ": " + logEvent.Exception.Message;
|
||||
}
|
||||
|
||||
|
||||
log.Exception = logEvent.Exception.ToString();
|
||||
log.ExceptionType = logEvent.Exception.GetType().ToString();
|
||||
}
|
||||
|
||||
|
||||
log.Level = logEvent.Level.Name;
|
||||
|
||||
|
||||
_database.Insert(log);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue