Jackett/src/Jackett.Common/Services/LogCacheService.cs

51 lines
1.1 KiB
C#
Raw Normal View History

using Jackett.Models;
using NLog;
using NLog.Targets;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Feature/netcore preparation (#2035) * Move to use package reference for restoring nuget packages. * Return a task result for this async method. * Update to a supported version of the .NET Framework. This also has the side effect of allowing us to automatically generate our binding redirects on build. * Set the solution to target VS2017 * Update test solution csproj file to support being built through MSBuild 15 * Move to use package reference for restoring nuget packages. * Return a task result for this async method. * Update to a supported version of the .NET Framework. This also has the side effect of allowing us to automatically generate our binding redirects on build. * Set the solution to target VS2017 * Update test solution csproj file to support being built through MSBuild 15 * DateTimeRoutines does not have Nuget packages that support .NET Standard (and therefore .NET Core). We will have to include them for now until we can get rid of this dependency. * Move the interfaces into their own files. This will be useful when we share them between the .NET Core and .NET Framework WebAPI * Stage services that need to point to the new interface namespace. * Update CurlSharp to fix memory leak issue and support better runtime compatibility with OSX and Linux * Start spliting some interfaces into their own files - this will help by allowing us to split them out in the future into a seperate project so the actual implementations can stay within their respective architectures when required
2017-10-29 10:19:09 +00:00
using Jackett.Services.Interfaces;
namespace Jackett.Services
{
[Target("LogService")]
public class LogCacheService: TargetWithLayout, ILogCacheService
{
private static List<CachedLog> logs = new List<CachedLog>();
public void AddLog(LogEventInfo l)
{
lock (logs)
{
logs.Insert(0, new CachedLog()
{
Level = l.Level.Name,
Message = l.Message,
When = l.TimeStamp
});
2015-08-07 21:40:45 +00:00
logs = logs.Take(50).ToList();
}
}
public List<CachedLog> Logs
{
get
{
lock (logs)
{
return logs.ToList();
}
}
}
protected override void Write(LogEventInfo logEvent)
{
AddLog(logEvent);
}
}
}