|
|
@ -3,6 +3,7 @@ using System.IO;
|
|
|
|
using System.Web;
|
|
|
|
using System.Web;
|
|
|
|
using Ninject;
|
|
|
|
using Ninject;
|
|
|
|
using NLog.Config;
|
|
|
|
using NLog.Config;
|
|
|
|
|
|
|
|
using NLog.Layouts;
|
|
|
|
using NLog.Targets;
|
|
|
|
using NLog.Targets;
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
@ -15,11 +16,13 @@ namespace NzbDrone.Core
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public static class CentralDispatch
|
|
|
|
public static class CentralDispatch
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
private static readonly Logger Logger = LogManager.GetLogger("DB");
|
|
|
|
|
|
|
|
|
|
|
|
public static void BindKernel(IKernel kernel)
|
|
|
|
public static void BindKernel(IKernel kernel)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string connectionString = String.Format("Data Source={0};Version=3;", Path.Combine(AppPath, "nzbdrone.db"));
|
|
|
|
string connectionString = String.Format("Data Source={0};Version=3;", Path.Combine(AppPath, "nzbdrone.db"));
|
|
|
|
var provider = ProviderFactory.GetProvider(connectionString, "System.Data.SQLite");
|
|
|
|
var provider = ProviderFactory.GetProvider(connectionString, "System.Data.SQLite");
|
|
|
|
|
|
|
|
provider.Log = new SonicTrace();
|
|
|
|
kernel.Bind<ISeriesProvider>().To<SeriesProvider>();
|
|
|
|
kernel.Bind<ISeriesProvider>().To<SeriesProvider>();
|
|
|
|
kernel.Bind<ISeasonProvider>().To<SeasonProvider>();
|
|
|
|
kernel.Bind<ISeasonProvider>().To<SeasonProvider>();
|
|
|
|
kernel.Bind<IEpisodeProvider>().To<EpisodeProvider>();
|
|
|
|
kernel.Bind<IEpisodeProvider>().To<EpisodeProvider>();
|
|
|
@ -50,42 +53,52 @@ namespace NzbDrone.Core
|
|
|
|
// Step 1. Create configuration object
|
|
|
|
// Step 1. Create configuration object
|
|
|
|
var config = new LoggingConfiguration();
|
|
|
|
var config = new LoggingConfiguration();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string callSight = "${callsite:className=false:fileName=true:includeSourcePath=false:methodName=true}";
|
|
|
|
|
|
|
|
|
|
|
|
// Step 2. Create targets and add them to the configuration
|
|
|
|
// Step 2. Create targets and add them to the configuration
|
|
|
|
var consoleTarget = new DebuggerTarget();
|
|
|
|
var debuggerTarget = new DebuggerTarget
|
|
|
|
config.AddTarget("console", consoleTarget);
|
|
|
|
{
|
|
|
|
|
|
|
|
Layout = callSight + "- ${logger}: ${message}"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var consoleTarget = new ColoredConsoleTarget
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Layout = callSight + ": ${message}"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
FileTarget fileTarget = new FileTarget();
|
|
|
|
|
|
|
|
config.AddTarget("file", fileTarget);
|
|
|
|
var fileTarget = new FileTarget
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FileName = "${basedir}/test.log",
|
|
|
|
|
|
|
|
Layout = "${message}"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config.AddTarget("debugger", debuggerTarget);
|
|
|
|
|
|
|
|
config.AddTarget("console", consoleTarget);
|
|
|
|
|
|
|
|
//config.AddTarget("file", fileTarget);
|
|
|
|
|
|
|
|
|
|
|
|
// Step 3. Set target properties
|
|
|
|
// Step 3. Set target properties
|
|
|
|
consoleTarget.Layout = "${logger} ${message}";
|
|
|
|
|
|
|
|
fileTarget.FileName = "${basedir}/test.log";
|
|
|
|
|
|
|
|
fileTarget.Layout = "${message}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Step 4. Define rules
|
|
|
|
// Step 4. Define rules
|
|
|
|
LoggingRule rule1 = new LoggingRule("*", LogLevel.Trace, consoleTarget);
|
|
|
|
LoggingRule debugRule = new LoggingRule("*", LogLevel.Trace, debuggerTarget);
|
|
|
|
config.LoggingRules.Add(rule1);
|
|
|
|
LoggingRule fileRule = new LoggingRule("*", LogLevel.Trace, fileTarget);
|
|
|
|
|
|
|
|
LoggingRule consoleRule = new LoggingRule("*", LogLevel.Trace, consoleTarget);
|
|
|
|
|
|
|
|
|
|
|
|
LoggingRule rule2 = new LoggingRule("*", LogLevel.Trace, fileTarget);
|
|
|
|
//config.LoggingRules.Add(fileRule);
|
|
|
|
config.LoggingRules.Add(rule2);
|
|
|
|
config.LoggingRules.Add(debugRule);
|
|
|
|
|
|
|
|
config.LoggingRules.Add(consoleRule);
|
|
|
|
|
|
|
|
|
|
|
|
// Step 5. Activate the configuration
|
|
|
|
// Step 5. Activate the configuration
|
|
|
|
NLog.LogManager.Configuration = config;
|
|
|
|
LogManager.Configuration = config;
|
|
|
|
|
|
|
|
|
|
|
|
Logger logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
|
|
logger.Trace("trace log message");
|
|
|
|
|
|
|
|
logger.Debug("debug log message");
|
|
|
|
|
|
|
|
logger.Info("info log message");
|
|
|
|
|
|
|
|
logger.Warn("warn log message");
|
|
|
|
|
|
|
|
logger.Error("error log message");
|
|
|
|
|
|
|
|
logger.Fatal("fatal log message");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void ForceMigration(IRepository repository)
|
|
|
|
private static void ForceMigration(IRepository repository)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
repository.GetPaged<Series>(0, 1);
|
|
|
|
repository.GetPaged<Series>(0, 1);
|
|
|
|
repository.GetPaged<EpisodeInfo>(0, 1);
|
|
|
|
repository.GetPaged<EpisodeInfo>(0, 1);
|
|
|
|
repository.GetPaged<Series>(0, 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|