Skip to content

Commit

Permalink
Merge pull request #316 from NLog/release/1.5.2
Browse files Browse the repository at this point in the history
Release 1.5.2
  • Loading branch information
304NotModified authored Jul 14, 2019
2 parents 896e715 + cb6a873 commit c28a9e8
Show file tree
Hide file tree
Showing 23 changed files with 740 additions and 160 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Date format: (year/month/day)

### v1.5.2 (2019/07/14)
- [#314](https://github.com/NLog/NLog.Extensions.Logging/pull/314) Added NLogProviderOptions.ShutdownOnDispose (#314) (@304NotModified)
- [#315](https://github.com/NLog/NLog.Extensions.Logging/pull/315) Update NLog to 4.6.5 (#315) (@304NotModified)

### V1.5.1 (2019/06/05)
- [#289](https://github.com/NLog/NLog.Extensions.Logging/pull/289) NLogBeginScopeParser - Improved exception handling (@snakefoot)
- [#299](https://github.com/NLog/NLog.Extensions.Logging/pull/299) Update dependency NLog ver. 4.6.4 (@snakefoot)
Expand Down
5 changes: 5 additions & 0 deletions NLog.Extensions.Logging.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=appsetting/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=configsetting/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=mldc/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ndlc/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# NLog.Extensions.Logging
![NLog](https://nlog-project.org/images/NLog.png)

# NLog.Extensions.Logging



[![NuGet Pre Release](https://img.shields.io/nuget/vpre/NLog.Extensions.Logging.svg)](https://www.nuget.org/packages/NLog.Extensions.Logging)
[![Build status Windows](https://ci.appveyor.com/api/projects/status/0nrg8cksp4b6tab1/branch/master?svg=true)](https://ci.appveyor.com/project/nlog/nlog-framework-logging/branch/master)
[![Build status Windows](https://ci.appveyor.com/api/projects/status/0nrg8cksp4b6tab1/branch/dev?svg=true)](https://ci.appveyor.com/project/nlog/nlog-framework-logging/branch/dev)
[![Build Status Linux](https://travis-ci.org/NLog/NLog.Extensions.Logging.svg?branch=master)](https://travis-ci.org/NLog/NLog.Extensions.Logging)

[![BCH compliance](https://bettercodehub.com/edge/badge/NLog/NLog.Extensions.Logging?branch=components)](https://bettercodehub.com/results/NLog/NLog.Extensions.Logging)
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&metric=ncloc)](https://sonarcloud.io/dashboard/?id=nlog.extensions.logging)
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&metric=bugs)](https://sonarcloud.io/dashboard/?id=nlog.extensions.logging)
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&metric=vulnerabilities)](https://sonarcloud.io/dashboard/?id=nlog.extensions.logging)
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&metric=code_smells)](https://sonarcloud.io/project/issues?id=nlog.extensions.logging&resolved=false&types=CODE_SMELL)
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&metric=duplicated_lines_density)](https://sonarcloud.io/component_measures/domain/Duplications?id=nlog.extensions.logging)
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&metric=sqale_debt_ratio)](https://sonarcloud.io/dashboard/?id=nlog.extensions.logging)
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&metric=coverage)](https://sonarcloud.io/component_measures?id=nlog.extensions.logging&metric=coverage)
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&branch=dev&metric=ncloc)](https://sonarcloud.io/dashboard/?id=nlog.extensions.logging&branch=dev)
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&branch=dev&metric=bugs)](https://sonarcloud.io/dashboard/?id=nlog.extensions.logging&branch=dev)
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&branch=dev&metric=vulnerabilities)](https://sonarcloud.io/dashboard/?id=nlog.extensions.logging&branch=dev)
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&branch=dev&metric=code_smells)](https://sonarcloud.io/project/issues?id=nlog.extensions.logging&branch=dev&resolved=false&types=CODE_SMELL)
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&branch=dev&metric=duplicated_lines_density)](https://sonarcloud.io/component_measures/domain/Duplications?id=nlog.extensions.logging&branch=dev)
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&branch=dev&metric=sqale_debt_ratio)](https://sonarcloud.io/dashboard/?id=nlog.extensions.logging&branch=dev)
[![](https://sonarcloud.io/api/project_badges/measure?project=nlog.extensions.logging&branch=dev&metric=coverage)](https://sonarcloud.io/component_measures?id=nlog.extensions.logging&branch=dev&metric=coverage)

[NLog](https://github.com/NLog/NLog) provider for [Microsoft.Extensions.Logging](https://github.com/aspnet/Logging); .NET Core.
**ASP.NET Core** users should install [NLog.Web.AspNetCore](https://www.nuget.org/packages/NLog.web.aspnetcore).
Expand Down
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# creates NuGet package at \artifacts
dotnet --version

$versionPrefix = "1.5.1"
$versionPrefix = "1.5.2"
$versionSuffix = ""
$versionFile = $versionPrefix + "." + ${env:APPVEYOR_BUILD_NUMBER}
$versionProduct = $versionPrefix;
Expand Down
1 change: 1 addition & 0 deletions src/NLog.Extensions.Hosting/NLog.Extensions.Hosting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Full changelog: https://github.com/NLog/NLog.Extensions.Logging/blob/master/CHAN
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<AssemblyOriginatorKeyFile>..\NLog.snk</AssemblyOriginatorKeyFile>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
31 changes: 20 additions & 11 deletions src/NLog.Extensions.Logging/Config/NLogLoggingConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public override IEnumerable<string> FileNamesToWatch
if (_autoReload && _reloadConfiguration == null)
{
// Prepare for setting up reload notification handling
_reloadConfiguration = state => ReloadConfigurationSection((IConfigurationSection) state);
_reloadConfiguration = state => ReloadConfigurationSection((IConfigurationSection)state);
LogFactory.ConfigurationChanged += LogFactory_ConfigurationChanged;
}

Expand Down Expand Up @@ -128,8 +128,8 @@ private class LoggingConfigurationElement : ILoggingConfigurationElement
private const string VariableKey = "Variable";
private const string DefaultWrapper = "Default-wrapper";
private readonly IConfigurationSection _configurationSection;
public IConfigurationSection DefaultTargetParametersSection { get; set; }
public IConfigurationSection DefaultTargetWrapperSection { get; set; }
private IConfigurationSection DefaultTargetParametersSection { get; set; }
private IConfigurationSection DefaultTargetWrapperSection { get; set; }
private readonly string _nameOverride;
private readonly bool _topElement;

Expand All @@ -138,9 +138,9 @@ public LoggingConfigurationElement(IConfigurationSection configurationSection, b
_configurationSection = configurationSection;
_nameOverride = nameOverride;
_topElement = topElement;
if (topElement && bool.TryParse(configurationSection["autoreload"], out var autoreload))
if (topElement && bool.TryParse(configurationSection["autoreload"], out var autoReload))
{
AutoReload = autoreload;
AutoReload = autoReload;
}
}

Expand Down Expand Up @@ -191,8 +191,6 @@ private IEnumerable<ILoggingConfigurationElement> GetChildren()
}

var isTargetsSection = IsTargetsSection();
var defaultTargetWrapper = GetDefaultWrapperSection();
var defaultTargetParameters = GetDefaultTargetParametersSection();

if (isTargetsSection)
{
Expand All @@ -203,9 +201,19 @@ private IEnumerable<ILoggingConfigurationElement> GetChildren()
}

var children = _configurationSection.GetChildren();
foreach (var loggingConfigurationElement in GetChildren(children, variables, isTargetsSection))
{
yield return loggingConfigurationElement;
}
}

private IEnumerable<ILoggingConfigurationElement> GetChildren(IEnumerable<IConfigurationSection> children, IConfigurationSection variables, bool isTargetsSection)
{
var defaultTargetWrapper = GetDefaultWrapperSection();
var defaultTargetParameters = GetDefaultTargetParametersSection();
foreach (var child in children)
{
if (AlreadReadChild(child, variables, defaultTargetWrapper, defaultTargetParameters))
if (AlreadyReadChild(child, variables, defaultTargetWrapper, defaultTargetParameters))
{
continue;
}
Expand All @@ -222,10 +230,11 @@ private IEnumerable<ILoggingConfigurationElement> GetChildren()
}
else
{
var isTargetKey = child.Key.EqualsOrdinalIgnoreCase(TargetsKey);
yield return new LoggingConfigurationElement(child, false, isTargetsSection ? TargetKey : null)
{
DefaultTargetParametersSection = (defaultTargetParameters != null && child.Key.EqualsOrdinalIgnoreCase(TargetsKey)) ? defaultTargetParameters : null,
DefaultTargetWrapperSection = (defaultTargetWrapper != null && child.Key.EqualsOrdinalIgnoreCase(TargetsKey)) ? defaultTargetWrapper : null,
DefaultTargetParametersSection = (defaultTargetParameters != null && isTargetKey) ? defaultTargetParameters : null,
DefaultTargetWrapperSection = (defaultTargetWrapper != null && isTargetKey) ? defaultTargetWrapper : null,
};
}
}
Expand Down Expand Up @@ -260,7 +269,7 @@ private IEnumerable<LoggingConfigurationElement> GetTargetsDefaultConfigElements
}
}

private bool AlreadReadChild(IConfigurationSection child, IConfigurationSection variables, IConfigurationSection defaultWrapper, IConfigurationSection defaultTargetParameters)
private bool AlreadyReadChild(IConfigurationSection child, IConfigurationSection variables, IConfigurationSection defaultWrapper, IConfigurationSection defaultTargetParameters)
{
if (_topElement)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using Microsoft.Extensions.Configuration;
using NLog.Common;
using NLog.Config;
Expand Down Expand Up @@ -46,7 +45,7 @@ public class ConfigSettingLayoutRenderer : LayoutRenderer
[DefaultParameter]
public string Item
{
get { return _item; }
get => _item;
set
{
_item = value;
Expand Down
16 changes: 8 additions & 8 deletions src/NLog.Extensions.Logging/Logging/NLogBeginScopeParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static IDisposable CaptureScopeProperties(IReadOnlyList<KeyValuePair<stri
return CreateScopeProperties(scopeObject, scopePropertyList);
}

public static IDisposable CaptureScopeProperties(IEnumerable scopePropertyCollection, ExtractorDictionary stateExractor)
public static IDisposable CaptureScopeProperties(IEnumerable scopePropertyCollection, ExtractorDictionary stateExtractor)
{
List<KeyValuePair<string, object>> propertyList = null;

Expand All @@ -125,7 +125,7 @@ public static IDisposable CaptureScopeProperties(IEnumerable scopePropertyCollec
break;
}

if (keyValueExtractor.Key == null && !TryLookupExtractor(stateExractor, property.GetType(), out keyValueExtractor))
if (keyValueExtractor.Key == null && !TryLookupExtractor(stateExtractor, property.GetType(), out keyValueExtractor))
{
break;
}
Expand All @@ -143,9 +143,9 @@ public static IDisposable CaptureScopeProperties(IEnumerable scopePropertyCollec
return CreateScopeProperties(scopePropertyCollection, propertyList);
}

public static IDisposable CaptureScopeProperty<TState>(TState scopeProperty, ExtractorDictionary stateExractor)
public static IDisposable CaptureScopeProperty<TState>(TState scopeProperty, ExtractorDictionary stateExtractor)
{
if (!TryLookupExtractor(stateExractor, scopeProperty.GetType(), out var keyValueExtractor))
if (!TryLookupExtractor(stateExtractor, scopeProperty.GetType(), out var keyValueExtractor))
{
return NestedDiagnosticsLogicalContext.Push(scopeProperty);
}
Expand Down Expand Up @@ -177,10 +177,10 @@ public static IDisposable CaptureScopeProperty<TState>(TState scopeProperty, Ext
}
}

private static bool TryLookupExtractor(ExtractorDictionary stateExractor, Type propertyType,
private static bool TryLookupExtractor(ExtractorDictionary stateExtractor, Type propertyType,
out KeyValuePair<Func<object, object>, Func<object, object>> keyValueExtractor)
{
if (!stateExractor.TryGetValue(propertyType, out keyValueExtractor))
if (!stateExtractor.TryGetValue(propertyType, out keyValueExtractor))
{
try
{
Expand All @@ -192,7 +192,7 @@ private static bool TryLookupExtractor(ExtractorDictionary stateExractor, Type p
}
finally
{
stateExractor[propertyType] = keyValueExtractor;
stateExtractor[propertyType] = keyValueExtractor;
}
}

Expand All @@ -201,7 +201,7 @@ private static bool TryLookupExtractor(ExtractorDictionary stateExractor, Type p

private static bool TryBuildExtractor(Type propertyType, out KeyValuePair<Func<object, object>, Func<object, object>> keyValueExtractor)
{
keyValueExtractor = default(KeyValuePair<Func<object, object>, Func<object, object>>);
keyValueExtractor = default;

var itemType = propertyType.GetTypeInfo();
if (!itemType.IsGenericType || itemType.GetGenericTypeDefinition() != typeof(KeyValuePair<,>))
Expand Down
Loading

0 comments on commit c28a9e8

Please sign in to comment.