mirror of https://github.com/lidarr/Lidarr
added file logging to services.
This commit is contained in:
parent
ad9a7fa6e4
commit
1d1c62d376
|
@ -28,7 +28,7 @@ namespace NzbDrone.Common.Test
|
||||||
const string badTitle = "Bad Title";
|
const string badTitle = "Bad Title";
|
||||||
|
|
||||||
ReportingService.ReportParseError(badTitle);
|
ReportingService.ReportParseError(badTitle);
|
||||||
MockedRestProvider.Verify(p => p.PostData(It.Is<string>(c => c.ToLower().StartsWith("http://service.nzbdrone.com/")), It.Is<ParseErrorReport>(c => c.Title == badTitle)), Times.Once());
|
MockedRestProvider.Verify(p => p.PostData(It.Is<string>(c => c.ToLower().StartsWith("http://services.nzbdrone.com/")), It.Is<ParseErrorReport>(c => c.Title == badTitle)), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -64,5 +64,14 @@ namespace NzbDrone.Common.Test
|
||||||
MockedRestProvider.Verify(p => p.PostData(It.IsAny<string>(), It.Is<ParseErrorReport>(c => c.Title == "title 2")), Times.Once());
|
MockedRestProvider.Verify(p => p.PostData(It.IsAny<string>(), It.Is<ParseErrorReport>(c => c.Title == "title 2")), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void report_parse_error()
|
||||||
|
{
|
||||||
|
ReportingService.RestProvider = new RestProvider(new EnviromentProvider());
|
||||||
|
ReportingService.ReportParseError("Test error");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -86,7 +86,7 @@ namespace NzbDrone.Common
|
||||||
fileTarget.ConcurrentWriteAttemptDelay = 50;
|
fileTarget.ConcurrentWriteAttemptDelay = 50;
|
||||||
fileTarget.ConcurrentWriteAttempts = 200;
|
fileTarget.ConcurrentWriteAttempts = 200;
|
||||||
|
|
||||||
fileTarget.Layout = @"${date:format=yy-M-d HH\:mm\:ss.f}|${replace:searchFor=NzbDrone.:replaceWith=:inner=${logger}}|${message}|${exception:format=ToString}";
|
fileTarget.Layout = @"${date:format=yy-M-d HH\:mm\:ss.f}|${replace:searchFor=NzbDrone.:replaceWith=:inner=${logger}}|${level}|${message}|${exception:format=ToString}";
|
||||||
|
|
||||||
return fileTarget;
|
return fileTarget;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
<Compile Include="ConsoleProvider.cs" />
|
<Compile Include="ConsoleProvider.cs" />
|
||||||
<Compile Include="Contract\ExceptionReport.cs" />
|
<Compile Include="Contract\ExceptionReport.cs" />
|
||||||
<Compile Include="Contract\ReportBase.cs" />
|
<Compile Include="Contract\ReportBase.cs" />
|
||||||
<Compile Include="Contract\ParseErrorRequ.cs" />
|
<Compile Include="Contract\ParseErrorReport.cs" />
|
||||||
<Compile Include="NlogTargets\RemoteTarget.cs" />
|
<Compile Include="NlogTargets\RemoteTarget.cs" />
|
||||||
<Compile Include="IISProvider.cs" />
|
<Compile Include="IISProvider.cs" />
|
||||||
<Compile Include="Model\AuthenticationType.cs" />
|
<Compile Include="Model\AuthenticationType.cs" />
|
||||||
|
|
|
@ -10,9 +10,9 @@ namespace NzbDrone.Common
|
||||||
{
|
{
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
private const string SERVICE_URL = "http://service.nzbdrone.com/reporting";
|
private const string SERVICE_URL = "http://services.nzbdrone.com/reporting";
|
||||||
private const string PARSE_URL = SERVICE_URL + "/parser";
|
private const string PARSE_URL = SERVICE_URL + "/ParseError";
|
||||||
private const string EXCEPTION_URL = SERVICE_URL + "/exception";
|
private const string EXCEPTION_URL = SERVICE_URL + "/ReportException";
|
||||||
|
|
||||||
public static RestProvider RestProvider { get; set; }
|
public static RestProvider RestProvider { get; set; }
|
||||||
private static readonly HashSet<string> parserErrorCache = new HashSet<string>();
|
private static readonly HashSet<string> parserErrorCache = new HashSet<string>();
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
using System.IO;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using NLog;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
using NzbDrone.Common.Contract;
|
using NzbDrone.Common.Contract;
|
||||||
|
@ -11,6 +13,9 @@ namespace NzbDrone.Common
|
||||||
|
|
||||||
public class RestProvider
|
public class RestProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnviromentProvider _enviromentProvider;
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +30,7 @@ namespace NzbDrone.Common
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private const int TIMEOUT = 10000;
|
private const int TIMEOUT = 15000;
|
||||||
private const string METHOD = "POST";
|
private const string METHOD = "POST";
|
||||||
|
|
||||||
public virtual void PostData(string url, ReportBase reportBase)
|
public virtual void PostData(string url, ReportBase reportBase)
|
||||||
|
@ -39,6 +44,8 @@ namespace NzbDrone.Common
|
||||||
|
|
||||||
|
|
||||||
private static void PostData(string url, object message)
|
private static void PostData(string url, object message)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var json = JsonConvert.SerializeObject(message);
|
var json = JsonConvert.SerializeObject(message);
|
||||||
|
|
||||||
|
@ -63,5 +70,11 @@ namespace NzbDrone.Common
|
||||||
var streamreader = new StreamReader(response.GetResponseStream());
|
var streamreader = new StreamReader(response.GetResponseStream());
|
||||||
streamreader.Close();
|
streamreader.Close();
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.Data.Add("URL", url);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
using System.Linq;
|
||||||
|
using NLog;
|
||||||
|
using NzbDrone.Common;
|
||||||
|
using NzbDrone.Services.Service.App_Start;
|
||||||
|
|
||||||
|
[assembly: WebActivator.PreApplicationStartMethod(typeof(Logging), "PreStart")]
|
||||||
|
|
||||||
|
namespace NzbDrone.Services.Service.App_Start
|
||||||
|
{
|
||||||
|
|
||||||
|
public static class Logging
|
||||||
|
{
|
||||||
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
public static void PreStart()
|
||||||
|
{
|
||||||
|
LogConfiguration.RegisterUdpLogger();
|
||||||
|
LogConfiguration.RegisterFileLogger("${basedir}/_logs/${shortdate}.log", LogLevel.Trace);
|
||||||
|
LogConfiguration.Reload();
|
||||||
|
|
||||||
|
logger.Info("Logger has been configured. (App Start)");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using Migrator.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Services.Service.Migrations
|
||||||
|
{
|
||||||
|
|
||||||
|
[Migration(20120205)]
|
||||||
|
public class Migration20120205 : Migration
|
||||||
|
{
|
||||||
|
public override void Up()
|
||||||
|
{
|
||||||
|
Database.ChangeColumn("ParseErrorReports", MigrationsHelper.VersionColumn);
|
||||||
|
Database.ChangeColumn("ExceptionReports", MigrationsHelper.VersionColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Down()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -46,7 +46,7 @@ namespace NzbDrone.Services.Service.Migrations
|
||||||
return String.Format("IX_{0}_{1}", tableName, String.Join("_", columns));
|
return String.Format("IX_{0}_{1}", tableName, String.Join("_", columns));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly Column VersionColumn = new Column("Version", DbType.String, 10, ColumnProperty.NotNull);
|
public static readonly Column VersionColumn = new Column("Version", DbType.String, 50, ColumnProperty.NotNull);
|
||||||
public static readonly Column ProductionColumn = new Column("IsProduction", DbType.Boolean, ColumnProperty.NotNull);
|
public static readonly Column ProductionColumn = new Column("IsProduction", DbType.Boolean, ColumnProperty.NotNull);
|
||||||
public static readonly Column TimestampColumn = new Column("TimeStamp", DbType.DateTime, ColumnProperty.NotNull);
|
public static readonly Column TimestampColumn = new Column("TimeStamp", DbType.DateTime, ColumnProperty.NotNull);
|
||||||
public static readonly Column UGuidColumn = new Column("UGuid", DbType.Guid, ColumnProperty.Null);
|
public static readonly Column UGuidColumn = new Column("UGuid", DbType.Guid, ColumnProperty.Null);
|
||||||
|
|
|
@ -108,6 +108,7 @@
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="App_Start\Logging.cs" />
|
||||||
<Compile Include="App_Start\NinjectMVC3.cs" />
|
<Compile Include="App_Start\NinjectMVC3.cs" />
|
||||||
<Compile Include="Datastore\Connection.cs" />
|
<Compile Include="Datastore\Connection.cs" />
|
||||||
<Compile Include="Controllers\DailySeriesController.cs" />
|
<Compile Include="Controllers\DailySeriesController.cs" />
|
||||||
|
@ -119,6 +120,7 @@
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="JsonModelBinder.cs" />
|
<Compile Include="JsonModelBinder.cs" />
|
||||||
<Compile Include="Migrations\Migration20120203.cs" />
|
<Compile Include="Migrations\Migration20120203.cs" />
|
||||||
|
<Compile Include="Migrations\Migration20120205.cs" />
|
||||||
<Compile Include="Migrations\Migration20120201.cs" />
|
<Compile Include="Migrations\Migration20120201.cs" />
|
||||||
<Compile Include="Migrations\MigrationHelper.cs" />
|
<Compile Include="Migrations\MigrationHelper.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
-->
|
-->
|
||||||
<system.web>
|
<system.web>
|
||||||
<compilation debug="false" xdt:Transform="Replace" />
|
<compilation debug="false" xdt:Transform="Replace" />
|
||||||
<customErrors mode="RemoteOnly" xdt:Transform="Replace"/>
|
<!--<customErrors mode="RemoteOnly" xdt:Transform="Replace"/>-->
|
||||||
<!--
|
<!--
|
||||||
In the example below, the "Replace" transform will replace the entire
|
In the example below, the "Replace" transform will replace the entire
|
||||||
<customErrors> section of your web.config file.
|
<customErrors> section of your web.config file.
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace NzbDrone.Services.Tests
|
||||||
{
|
{
|
||||||
IsProduction = true,
|
IsProduction = true,
|
||||||
Title = "MyTitle",
|
Title = "MyTitle",
|
||||||
Version = "1.1.2.3",
|
Version = "1.1.2.323456",
|
||||||
UGuid = Guid.NewGuid()
|
UGuid = Guid.NewGuid()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ namespace NzbDrone.Services.Tests
|
||||||
return new ExceptionReport
|
return new ExceptionReport
|
||||||
{
|
{
|
||||||
IsProduction = true,
|
IsProduction = true,
|
||||||
Version = "1.1.2.3",
|
Version = "1.1.2.323456",
|
||||||
UGuid = Guid.NewGuid(),
|
UGuid = Guid.NewGuid(),
|
||||||
Logger = "NzbDrone.Logger.Name",
|
Logger = "NzbDrone.Logger.Name",
|
||||||
LogMessage = "Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message",
|
LogMessage = "Long message Long message Long messageLong messageLong messageLong messageLong messageLong messageLong messageLong messageLong message",
|
||||||
|
|
Loading…
Reference in New Issue