mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
replaced owin's ITraceOutputFactory to one based on nlog that should work on linux.
This commit is contained in:
parent
b75aad1268
commit
9b9e1e20eb
@ -1,4 +1,5 @@
|
||||
using Nancy.Bootstrapper;
|
||||
using System;
|
||||
using Nancy.Bootstrapper;
|
||||
using NzbDrone.Api;
|
||||
using NzbDrone.Api.SignalR;
|
||||
using NzbDrone.Common.Composition;
|
||||
@ -6,6 +7,7 @@
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
using NzbDrone.Host.Owin;
|
||||
|
||||
namespace NzbDrone.Host
|
||||
{
|
||||
@ -24,6 +26,7 @@ private MainAppContainerBuilder(StartupArguments args)
|
||||
|
||||
Container.Register(typeof(IBasicRepository<RootFolder>), typeof(BasicRepository<RootFolder>));
|
||||
Container.Register(typeof(IBasicRepository<NamingConfig>), typeof(BasicRepository<NamingConfig>));
|
||||
Container.Register(typeof(System.IServiceProvider), typeof(OwinServiceProvider));
|
||||
|
||||
Container.Register<INancyBootstrapper, NancyBootstrapper>();
|
||||
}
|
||||
|
@ -122,6 +122,9 @@
|
||||
<Compile Include="AccessControl\FirewallAdapter.cs" />
|
||||
<Compile Include="AccessControl\UrlAclAdapter.cs" />
|
||||
<Compile Include="IUserAlert.cs" />
|
||||
<Compile Include="Owin\NlogTextWriter.cs" />
|
||||
<Compile Include="Owin\OwinServiceProvider.cs" />
|
||||
<Compile Include="Owin\OwinTraceOutputFactory.cs" />
|
||||
<Compile Include="PlatformValidation.cs" />
|
||||
<Compile Include="MainAppContainerBuilder.cs" />
|
||||
<Compile Include="ApplicationModes.cs" />
|
||||
|
41
NzbDrone.Host/Owin/NlogTextWriter.cs
Normal file
41
NzbDrone.Host/Owin/NlogTextWriter.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using NLog;
|
||||
|
||||
namespace NzbDrone.Host.Owin
|
||||
{
|
||||
public class NlogTextWriter : TextWriter
|
||||
{
|
||||
private readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
|
||||
public override Encoding Encoding
|
||||
{
|
||||
get
|
||||
{
|
||||
return Encoding.Default;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Write(char value)
|
||||
{
|
||||
logger.Trace(value);
|
||||
}
|
||||
|
||||
public override void Write(char[] buffer)
|
||||
{
|
||||
logger.Trace(buffer);
|
||||
}
|
||||
|
||||
public override void Write(string value)
|
||||
{
|
||||
logger.Trace(value);
|
||||
}
|
||||
|
||||
public override void Write(char[] buffer, int index, int count)
|
||||
{
|
||||
logger.Trace(buffer);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -14,13 +14,15 @@ public class OwinHostController : IHostController
|
||||
{
|
||||
private readonly IConfigFileProvider _configFileProvider;
|
||||
private readonly IEnumerable<IOwinMiddleWare> _owinMiddleWares;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly Logger _logger;
|
||||
private IDisposable _host;
|
||||
|
||||
public OwinHostController(IConfigFileProvider configFileProvider, IEnumerable<IOwinMiddleWare> owinMiddleWares, Logger logger)
|
||||
public OwinHostController(IConfigFileProvider configFileProvider, IEnumerable<IOwinMiddleWare> owinMiddleWares, IServiceProvider serviceProvider, Logger logger)
|
||||
{
|
||||
_configFileProvider = configFileProvider;
|
||||
_owinMiddleWares = owinMiddleWares;
|
||||
_serviceProvider = serviceProvider;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@ -37,7 +39,7 @@ public void StartServer()
|
||||
|
||||
_logger.Info("starting server on {0}", url);
|
||||
|
||||
_host = WebApp.Start(options, BuildApp);
|
||||
_host = WebApp.Start(_serviceProvider, options, BuildApp);
|
||||
}
|
||||
|
||||
private void BuildApp(IAppBuilder appBuilder)
|
||||
|
25
NzbDrone.Host/Owin/OwinServiceProvider.cs
Normal file
25
NzbDrone.Host/Owin/OwinServiceProvider.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using Microsoft.Owin.Hosting.Services;
|
||||
using Microsoft.Owin.Hosting.Tracing;
|
||||
|
||||
namespace NzbDrone.Host.Owin
|
||||
{
|
||||
public class OwinServiceProvider : IServiceProvider
|
||||
{
|
||||
private readonly IServiceProvider _defaultProvider;
|
||||
|
||||
public OwinServiceProvider()
|
||||
{
|
||||
_defaultProvider = ServicesFactory.Create();
|
||||
}
|
||||
public object GetService(Type serviceType)
|
||||
{
|
||||
if (serviceType == typeof (ITraceOutputFactory))
|
||||
{
|
||||
return new OwinTraceOutputFactory();
|
||||
}
|
||||
|
||||
return _defaultProvider.GetService(serviceType);
|
||||
}
|
||||
}
|
||||
}
|
14
NzbDrone.Host/Owin/OwinTraceOutputFactory.cs
Normal file
14
NzbDrone.Host/Owin/OwinTraceOutputFactory.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.IO;
|
||||
using Microsoft.Owin.Hosting.Tracing;
|
||||
|
||||
namespace NzbDrone.Host.Owin
|
||||
{
|
||||
public class OwinTraceOutputFactory : ITraceOutputFactory
|
||||
{
|
||||
|
||||
public TextWriter Create(string outputFile)
|
||||
{
|
||||
return new NlogTextWriter();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user