1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-27 01:57:21 +00:00

tweaked logging tests.

This commit is contained in:
kay.one 2013-03-26 21:03:02 -07:00
parent 22bbf83e42
commit ccba527e89
4 changed files with 26 additions and 4 deletions

View file

@ -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);
}

View file

@ -20,6 +20,14 @@ public class DatabaseTargetFixture : DbTest<DatabaseTarget, Log>
private static string _uniqueMessage;
Logger _logger;
protected override MigrationType MigrationType
{
get
{
return MigrationType.Log;
}
}
[SetUp]
public void Setup()
{

View file

@ -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();

View file

@ -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."))