mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 02:37:08 -07:00
fixed a bunch of things. added basic support for file scanning. logs are now avilable in the UI
This commit is contained in:
parent
c8a8fb4d62
commit
fa0af257ff
48 changed files with 914 additions and 208 deletions
78
NzbDrone.Core/Instrumentation/SubsonicTarget.cs
Normal file
78
NzbDrone.Core/Instrumentation/SubsonicTarget.cs
Normal file
|
@ -0,0 +1,78 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using Exceptioneer.WindowsFormsClient;
|
||||
using NLog;
|
||||
using NLog.Targets;
|
||||
using SubSonic.Repository;
|
||||
using Ninject;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
namespace NzbDrone.Core.Instrumentation
|
||||
{
|
||||
public class SubsonicTarget : Target
|
||||
{
|
||||
private readonly IRepository _repo;
|
||||
|
||||
public SubsonicTarget(IRepository repo)
|
||||
{
|
||||
_repo = repo;
|
||||
}
|
||||
|
||||
protected override void Write(LogEventInfo logEvent)
|
||||
{
|
||||
var log = new Log();
|
||||
log.Time = logEvent.TimeStamp;
|
||||
log.Message = logEvent.FormattedMessage;
|
||||
|
||||
if (log.Stack != null)
|
||||
{
|
||||
log.Stack = logEvent.StackTrace.ToString();
|
||||
}
|
||||
|
||||
log.Logger = logEvent.LoggerName;
|
||||
|
||||
if (logEvent.Exception != null)
|
||||
{
|
||||
log.ExceptionMessage = logEvent.Exception.Message;
|
||||
log.ExceptionString = logEvent.Exception.ToString();
|
||||
log.ExceptionType = logEvent.Exception.GetType().ToString();
|
||||
}
|
||||
|
||||
switch (logEvent.Level.Name.ToLower())
|
||||
{
|
||||
case "trace":
|
||||
{
|
||||
log.Level = LogLevel.Trace;
|
||||
break;
|
||||
}
|
||||
case "debug":
|
||||
{
|
||||
log.Level = LogLevel.Debug;
|
||||
break;
|
||||
}
|
||||
case "info":
|
||||
{
|
||||
log.Level = LogLevel.Info;
|
||||
break;
|
||||
}
|
||||
case "warn":
|
||||
{
|
||||
log.Level = LogLevel.Warn;
|
||||
break;
|
||||
}
|
||||
case "error":
|
||||
{
|
||||
log.Level = LogLevel.Error;
|
||||
break;
|
||||
}
|
||||
case "fatal":
|
||||
{
|
||||
log.Level = LogLevel.Fatal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_repo.Add(log);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue