From ccba527e890435c982a0cbf4dea47787e957ac58 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Tue, 26 Mar 2013 21:03:02 -0700 Subject: [PATCH] tweaked logging tests. --- NzbDrone.Core.Test/Framework/DbTest.cs | 12 +++++++++++- .../InstrumentationTests/DatabaseTargetFixture.cs | 8 ++++++++ .../Datastore/Migration/Migration20130324.cs | 4 ++-- NzbDrone.Core/Instrumentation/DatabaseTarget.cs | 6 +++++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/NzbDrone.Core.Test/Framework/DbTest.cs b/NzbDrone.Core.Test/Framework/DbTest.cs index f43d3070b..86fa4408a 100644 --- a/NzbDrone.Core.Test/Framework/DbTest.cs +++ b/NzbDrone.Core.Test/Framework/DbTest.cs @@ -68,6 +68,16 @@ public abstract class DbTest : CoreTest private ITestDatabase _db; private IDatabase _database; + + protected virtual MigrationType MigrationType + { + get + { + return MigrationType.Main; + + } + } + protected ITestDatabase Db { get @@ -87,7 +97,7 @@ private void WithObjectDb(bool memory = true) MapRepository.Instance.EnableTraceLogging = true; var factory = new DbFactory(new MigrationController(new NlogAnnouncer())); - _database = factory.Create(_dbName); + _database = factory.Create(_dbName, MigrationType); _db = new TestTestDatabase(_database); Mocker.SetConstant(_database); } diff --git a/NzbDrone.Core.Test/InstrumentationTests/DatabaseTargetFixture.cs b/NzbDrone.Core.Test/InstrumentationTests/DatabaseTargetFixture.cs index d9a66b371..91624f0ec 100644 --- a/NzbDrone.Core.Test/InstrumentationTests/DatabaseTargetFixture.cs +++ b/NzbDrone.Core.Test/InstrumentationTests/DatabaseTargetFixture.cs @@ -20,6 +20,14 @@ public class DatabaseTargetFixture : DbTest private static string _uniqueMessage; Logger _logger; + protected override MigrationType MigrationType + { + get + { + return MigrationType.Log; + + } + } [SetUp] public void Setup() { diff --git a/NzbDrone.Core/Datastore/Migration/Migration20130324.cs b/NzbDrone.Core/Datastore/Migration/Migration20130324.cs index 9db11b5eb..adf29adff 100644 --- a/NzbDrone.Core/Datastore/Migration/Migration20130324.cs +++ b/NzbDrone.Core/Datastore/Migration/Migration20130324.cs @@ -151,11 +151,11 @@ protected override void MainDbUpgrade() protected override void LogDbUpgrade() { Create.Table("Logs") - .WithColumn("LogId").AsInt64().PrimaryKey().Identity() + .WithColumn("Id").AsInt32().PrimaryKey().Identity() .WithColumn("Message").AsString().NotNullable() .WithColumn("Time").AsDateTime().NotNullable() .WithColumn("Logger").AsString().NotNullable() - .WithColumn("Method").AsString().NotNullable() + .WithColumn("Method").AsString().Nullable() .WithColumn("Exception").AsString().Nullable() .WithColumn("ExceptionType").AsString().Nullable() .WithColumn("Level").AsString().NotNullable(); diff --git a/NzbDrone.Core/Instrumentation/DatabaseTarget.cs b/NzbDrone.Core/Instrumentation/DatabaseTarget.cs index 7d15b947f..8dc00809e 100644 --- a/NzbDrone.Core/Instrumentation/DatabaseTarget.cs +++ b/NzbDrone.Core/Instrumentation/DatabaseTarget.cs @@ -31,7 +31,11 @@ protected override void Write(LogEventInfo logEvent) log.Time = logEvent.TimeStamp; log.Message = logEvent.FormattedMessage; - log.Method = logEvent.UserStackFrame.GetMethod().Name; + if (logEvent.UserStackFrame != null) + { + log.Method = logEvent.UserStackFrame.GetMethod().Name; + } + log.Logger = logEvent.LoggerName; if (log.Logger.StartsWith("NzbDrone."))