-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from Sergei-Y/fix_issue_34
Fix issue #34
- Loading branch information
Showing
7 changed files
with
102 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using JetBrains.Annotations; | ||
using ZeroLog.Appenders; | ||
|
||
namespace ZeroLog.Tests.ExternalAppender | ||
{ | ||
[UsedImplicitly] | ||
public class TestAppender : ConsoleAppender | ||
{ | ||
public TestAppender() | ||
{ | ||
} | ||
|
||
public TestAppender(string prefixPattern) | ||
: base(prefixPattern) | ||
{ | ||
} | ||
|
||
public override void Configure(DefaultAppenderConfig parameters) | ||
{ | ||
parameters.PrefixPattern = $"({Name}): {parameters.PrefixPattern}"; | ||
base.Configure(parameters); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/ZeroLog.Tests.ExternalAppender/ZeroLog.Tests.ExternalAppender.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ZeroLog\ZeroLog.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System.Linq; | ||
using NUnit.Framework; | ||
using ZeroLog.Appenders; | ||
using ZeroLog.Config; | ||
using ZeroLog.ConfigResolvers; | ||
|
||
namespace ZeroLog.Tests.Appenders | ||
{ | ||
[TestFixture] | ||
public class ExternalAppenderTest | ||
{ | ||
[Test] | ||
public void should_resolve_appender_from_assembly_qualified_name() | ||
{ | ||
var appenderDef = new AppenderDefinition | ||
{ | ||
Name = "ExtApp1", | ||
AppenderTypeName = "ZeroLog.Tests.ExternalAppender.TestAppender, ZeroLog.Tests.ExternalAppender", | ||
AppenderJsonConfig = new DefaultAppenderConfig { PrefixPattern = "[%level] @ %time - %logger: " } | ||
}; | ||
|
||
var config = new ZeroLogJsonConfiguration | ||
{ | ||
LogEventBufferSize = 5, | ||
LogEventQueueSize = 7, | ||
RootLogger = new LoggerDefinition | ||
{ | ||
Level = Level.Info, | ||
LogEventPoolExhaustionStrategy = LogEventPoolExhaustionStrategy.DropLogMessage, | ||
AppenderReferences = new[] { "ExtApp1" }, | ||
}, | ||
Appenders = new[] { appenderDef }, | ||
}; | ||
|
||
var configResolver = new HierarchicalResolver(); | ||
configResolver.Build(config); | ||
|
||
var appenders = configResolver.GetAllAppenders().ToList(); | ||
Assert.AreEqual(1, appenders.Count); | ||
Assert.AreEqual("ZeroLog.Tests.ExternalAppender.TestAppender", ((GuardedAppender)appenders[0]).Appender.GetType().FullName); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters