|
|
@ -1,12 +1,13 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Threading;
|
|
|
|
using FluentAssertions;
|
|
|
|
using FluentAssertions;
|
|
|
|
using Marr.Data;
|
|
|
|
using Marr.Data;
|
|
|
|
using NLog;
|
|
|
|
using NLog;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NzbDrone.Common.Instrumentation;
|
|
|
|
using NzbDrone.Common.Instrumentation;
|
|
|
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
|
|
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Instrumentation;
|
|
|
|
using NzbDrone.Core.Instrumentation;
|
|
|
|
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
using NzbDrone.Test.Common.Categories;
|
|
|
|
using NzbDrone.Test.Common.Categories;
|
|
|
@ -35,7 +36,6 @@ namespace NzbDrone.Core.Test.InstrumentationTests
|
|
|
|
|
|
|
|
|
|
|
|
LogManager.ReconfigExistingLoggers();
|
|
|
|
LogManager.ReconfigExistingLoggers();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger = NzbDroneLogger.GetLogger(this);
|
|
|
|
_logger = NzbDroneLogger.GetLogger(this);
|
|
|
|
|
|
|
|
|
|
|
|
_uniqueMessage = "Unique message: " + Guid.NewGuid();
|
|
|
|
_uniqueMessage = "Unique message: " + Guid.NewGuid();
|
|
|
@ -46,6 +46,8 @@ namespace NzbDrone.Core.Test.InstrumentationTests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.Info(_uniqueMessage);
|
|
|
|
_logger.Info(_uniqueMessage);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(600);
|
|
|
|
|
|
|
|
|
|
|
|
StoredModel.Message.Should().Be(_uniqueMessage);
|
|
|
|
StoredModel.Message.Should().Be(_uniqueMessage);
|
|
|
|
VerifyLog(StoredModel, LogLevel.Info);
|
|
|
|
VerifyLog(StoredModel, LogLevel.Info);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -61,6 +63,8 @@ namespace NzbDrone.Core.Test.InstrumentationTests
|
|
|
|
|
|
|
|
|
|
|
|
_logger.Info(message);
|
|
|
|
_logger.Info(message);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(600);
|
|
|
|
|
|
|
|
|
|
|
|
StoredModel.Message.Should().HaveLength(message.Length);
|
|
|
|
StoredModel.Message.Should().HaveLength(message.Length);
|
|
|
|
StoredModel.Message.Should().Be(message);
|
|
|
|
StoredModel.Message.Should().Be(message);
|
|
|
|
VerifyLog(StoredModel, LogLevel.Info);
|
|
|
|
VerifyLog(StoredModel, LogLevel.Info);
|
|
|
@ -77,6 +81,9 @@ namespace NzbDrone.Core.Test.InstrumentationTests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.Info(Guid.NewGuid());
|
|
|
|
_logger.Info(Guid.NewGuid());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(600);
|
|
|
|
|
|
|
|
|
|
|
|
MapRepository.Instance.EnableTraceLogging = true;
|
|
|
|
MapRepository.Instance.EnableTraceLogging = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -87,6 +94,7 @@ namespace NzbDrone.Core.Test.InstrumentationTests
|
|
|
|
|
|
|
|
|
|
|
|
_logger.Error(ex, _uniqueMessage);
|
|
|
|
_logger.Error(ex, _uniqueMessage);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(600);
|
|
|
|
|
|
|
|
|
|
|
|
VerifyLog(StoredModel, LogLevel.Error);
|
|
|
|
VerifyLog(StoredModel, LogLevel.Error);
|
|
|
|
StoredModel.Message.Should().Be(_uniqueMessage + ": " + ex.Message);
|
|
|
|
StoredModel.Message.Should().Be(_uniqueMessage + ": " + ex.Message);
|
|
|
@ -99,13 +107,13 @@ namespace NzbDrone.Core.Test.InstrumentationTests
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void exception_log_with_no_message_should_use_exceptions_message()
|
|
|
|
public void exception_log_with_no_message_should_use_exceptions_message()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var ex = new InvalidOperationException("Fake Exception");
|
|
|
|
var ex = new InvalidOperationException("Fake Exception");
|
|
|
|
_uniqueMessage = string.Empty;
|
|
|
|
_uniqueMessage = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.Error(ex, _uniqueMessage);
|
|
|
|
_logger.Error(ex, _uniqueMessage);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(600);
|
|
|
|
|
|
|
|
|
|
|
|
StoredModel.Message.Should().Be(ex.Message);
|
|
|
|
StoredModel.Message.Should().Be(ex.Message);
|
|
|
|
|
|
|
|
|
|
|
|
VerifyLog(StoredModel, LogLevel.Error);
|
|
|
|
VerifyLog(StoredModel, LogLevel.Error);
|
|
|
@ -119,6 +127,8 @@ namespace NzbDrone.Core.Test.InstrumentationTests
|
|
|
|
var epFile = new EpisodeFile();
|
|
|
|
var epFile = new EpisodeFile();
|
|
|
|
_logger.Debug("File {0} no longer exists on disk. removing from database.", epFile.RelativePath);
|
|
|
|
_logger.Debug("File {0} no longer exists on disk. removing from database.", epFile.RelativePath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(600);
|
|
|
|
|
|
|
|
|
|
|
|
epFile.RelativePath.Should().BeNull();
|
|
|
|
epFile.RelativePath.Should().BeNull();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|