mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using NLog;
|
|
using NLog.Config;
|
|
using NLog.Targets;
|
|
using NUnit.Framework;
|
|
using NzbDrone.Common;
|
|
|
|
namespace NzbDrone.Test.Common
|
|
{
|
|
public abstract class LoggingTest
|
|
{
|
|
|
|
protected Logger TestLogger = LogManager.GetLogger("TestLogger");
|
|
|
|
protected static void InitLogging()
|
|
{
|
|
if (LogManager.Configuration == null || LogManager.Configuration is XmlLoggingConfiguration)
|
|
{
|
|
LogManager.Configuration = new LoggingConfiguration();
|
|
var consoleTarget = new ConsoleTarget { Layout = "${message} ${exception}" };
|
|
LogManager.Configuration.AddTarget(consoleTarget.GetType().Name, consoleTarget);
|
|
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, consoleTarget));
|
|
|
|
RegisterExceptionVerification();
|
|
}
|
|
}
|
|
|
|
private static void RegisterExceptionVerification()
|
|
{
|
|
var exceptionVerification = new ExceptionVerification();
|
|
LogManager.Configuration.AddTarget("ExceptionVerification", exceptionVerification);
|
|
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Warn, exceptionVerification));
|
|
}
|
|
|
|
[SetUp]
|
|
public void LoggingTestSetup()
|
|
{
|
|
InitLogging();
|
|
ExceptionVerification.Reset();
|
|
}
|
|
|
|
[TearDown]
|
|
public void LoggingDownBase()
|
|
{
|
|
ExceptionVerification.AssertNoUnexcpectedLogs();
|
|
}
|
|
}
|
|
}
|