-
Notifications
You must be signed in to change notification settings - Fork 8
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 #5 from GokGokalp/develop
Some refactoring
- Loading branch information
Showing
8 changed files
with
91 additions
and
6 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,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd"> | ||
<metadata> | ||
<id>NLog.Web.AspNetCore.Targets.Gelf</id> | ||
<version>1.1.0</version> | ||
<title>NLog.Web.AspNetCore.Targets.Gelf</title> | ||
<authors>Gökhan Gökalp</authors> | ||
<owners>Gökhan Gökalp</owners> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<licenseUrl>https://github.com/GokGokalp/NLog.Web.AspNetCore.Targets.Gelf/blob/master/LICENSE</licenseUrl> | ||
<projectUrl>https://github.com/GokGokalp/NLog.Web.AspNetCore.Targets.Gelf</projectUrl> | ||
<description>Gelf4NLog is an NLog target implementation to push log messages to GrayLog2.</description> | ||
<copyright>Copyright 2018</copyright> | ||
<tags>gelf graylog2 nlog</tags> | ||
<dependencies> | ||
<group targetFramework=".NETStandard2.0"> | ||
<dependency id="Newtonsoft.Json" version="10.0.2" exclude="Build,Analyzers" /> | ||
<dependency id="System.ComponentModel.Annotations" version="4.3.0" exclude="Build,Analyzers" /> | ||
<dependency id="NLog.Extensions.Logging" version="1.0.2" /> | ||
</group> | ||
</dependencies> | ||
</metadata> | ||
<files> | ||
<file src="lib\netstandard2.0\NLog.Web.AspNetCore.Targets.Gelf.dll" target="lib\netstandard2.0\NLog.Web.AspNetCore.Targets.Gelf.dll" /> | ||
</files> | ||
</package> |
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
38 changes: 38 additions & 0 deletions
38
NLog.Web.AspNetCore.Targets.Gelf.Tests/GelfConverterTests.cs
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,38 @@ | ||
using Xunit; | ||
|
||
namespace NLog.Web.AspNetCore.Targets.Gelf.Tests | ||
{ | ||
public class GelfConverterTests | ||
{ | ||
[Fact] | ||
public void ShouldGetGelfJsonAddMappedDiagnosticsLogicalContextData() | ||
{ | ||
MappedDiagnosticsLogicalContext.Set("test", "value"); | ||
|
||
var logEvent = LogEventInfo.Create(LogLevel.Info, "loggerName", null, "message"); | ||
|
||
var converter = new GelfConverter(); | ||
|
||
// Act | ||
var gelfJson = converter.GetGelfJson(logEvent, "facility"); | ||
|
||
Assert.Equal("value", gelfJson.Value<string>("_test")); | ||
} | ||
|
||
[Fact] | ||
public void ShouldGetGelfJsonDiscardMappedDiagnosticsLogicalContextDataIfPresentInLogEventInfo() | ||
{ | ||
MappedDiagnosticsLogicalContext.Set("test", "value"); | ||
|
||
var logEvent = LogEventInfo.Create(LogLevel.Info, "loggerName", null, "message"); | ||
logEvent.Properties.Add("test", "anotherValue"); | ||
|
||
var converter = new GelfConverter(); | ||
|
||
// Act | ||
var gelfJson = converter.GetGelfJson(logEvent, "facility"); | ||
|
||
Assert.Equal("anotherValue", gelfJson.Value<string>("_test")); | ||
} | ||
} | ||
} |
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
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