Skip to content

Commit 76bcc92

Browse files
committed
Bumped references and framework version. Updated nulabillity for ILogger extensions. The Testing project was updated with a TestCorrelationProviderAccessor, for use with dependency injection. AddTestLogger method will register it as scoped.
1 parent 66d26bd commit 76bcc92

File tree

17 files changed

+97
-66
lines changed

17 files changed

+97
-66
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ using static com.github.akovac35.Logging.LoggerHelper<WebApp.Pages.Counter>
123123
Here(l => l.LogInformation("currentCount: {0}", currentCount));
124124
```
125125

126-
It is important to note that instead of using reflection, invocation context is determined with the help of compiler service attributes, which minimizes performance impact. Benchmarking revealed that invocation overhead of ```_logger.Here(Action<ILogger> logAction)``` versus direct logger method invocation is about 30%, which is negligible.
126+
It is important to note that instead of using reflection, invocation context is determined with the help of compiler service attributes, which minimizes performance impact. Benchmarking revealed that invocation overhead of ```_logger.Here(Action<ILogger> logAction)``` versus direct logger method invocation is less than 20%, which is negligible.
127127

128128
When this functionality is not disabled, invocation context is passed to logger frameworks via ```ILogger.BeginScope()```, as follows:
129129

@@ -472,6 +472,7 @@ ATN! - will not render as perhaps expected, only the first array element will be
472472
* 1.1.0 - Not using ```HttpContext``` for log correlation anymore - use ```CorrelationProvider.CurrentCorrelationProvider?.GetCorrelationId()``` to obtain the correlation value for the current ambient context. Made it easier to wire up logging services by introducing the ```AddLoggingCorrelation```, ```UseLoggingCorrelation``` and ```AddTestLogger``` extension methods. The ```CorrelationIdMiddleware``` was renamed to ```LoggingCorrelationMiddleware```. Updated dependencies. Removed ASP.NET Core projects containing NLog and Serilog helper code because it is no longer needed. Switched to using abstractions as much as possible.
473473
* 1.1.1 - Added CorrelationProviderAccessor.
474474
* 1.1.2 - Made the Current property of CorrelationProviderAccessor virtual.
475+
* 1.2.0 - Bumped references and framework version. Updated nulabillity for ILogger extensions.
475476

476477
## Contributing
477478
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

global.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"sdk": {
3+
"allowPrerelease": true
4+
}
5+
}

remove_bin_obj.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
find . -type d -iname "bin" -o -iname "obj" | xargs rm -r

src/com.github.akovac35.Logging.AspNetCore/com.github.akovac35.Logging.AspNetCore.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
<PropertyGroup>
44
<Description>Helpful resources for .NET Core and ASP.NET Core logging using various logger frameworks and Microsoft.Extensions.Logging.ILogger interface.</Description>
5-
<VersionPrefix>1.1.2</VersionPrefix>
5+
<Version>1.2.0</Version>
66
<Authors>Aleksander Kovač</Authors>
7-
<TargetFrameworks>netstandard2.1</TargetFrameworks>
7+
<TargetFrameworks>net5.0</TargetFrameworks>
88
<PackageTags>logging;serilog;nlog;correlation</PackageTags>
99
<RepositoryUrl>https://github.com/akovac35/Logging</RepositoryUrl>
1010
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
1111
<IncludeSymbols>true</IncludeSymbols>
1212
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1313
<PackageIcon>.NET_Core_Logo.png</PackageIcon>
1414
<RepositoryType>git</RepositoryType>
15-
<PackageReleaseNotes>Updated Logging version.</PackageReleaseNotes>
15+
<PackageReleaseNotes>Bumped references and framework version.</PackageReleaseNotes>
1616

1717
<Nullable>enable</Nullable>
1818
<LangVersion>latest</LangVersion>
@@ -28,7 +28,7 @@
2828

2929
<ItemGroup>
3030
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
31-
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.5" />
31+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
3232
</ItemGroup>
3333

3434
</Project>

src/com.github.akovac35.Logging.NLog/com.github.akovac35.Logging.NLog.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
<PropertyGroup>
44
<Description>Helpful resources for .NET Core and ASP.NET Core logging using various logger frameworks and Microsoft.Extensions.Logging.ILogger interface.</Description>
5-
<VersionPrefix>1.1.2</VersionPrefix>
5+
<Version>1.2.0</Version>
66
<Authors>Aleksander Kovač</Authors>
7-
<TargetFrameworks>netstandard2.1</TargetFrameworks>
7+
<TargetFrameworks>net5.0</TargetFrameworks>
88
<PackageTags>logging;serilog;nlog;correlation</PackageTags>
99
<RepositoryUrl>https://github.com/akovac35/Logging</RepositoryUrl>
1010
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
1111
<IncludeSymbols>true</IncludeSymbols>
1212
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1313
<PackageIcon>.NET_Core_Logo.png</PackageIcon>
1414
<RepositoryType>git</RepositoryType>
15-
<PackageReleaseNotes>Updated Logging version.</PackageReleaseNotes>
15+
<PackageReleaseNotes>Bumped references and framework version.</PackageReleaseNotes>
1616

1717
<Nullable>enable</Nullable>
1818
<LangVersion>latest</LangVersion>
@@ -21,7 +21,7 @@
2121
</PropertyGroup>
2222

2323
<ItemGroup>
24-
<PackageReference Include="NLog.Extensions.Logging" Version="1.6.4" />
24+
<PackageReference Include="NLog.Extensions.Logging" Version="1.7.3" />
2525
</ItemGroup>
2626

2727
<ItemGroup>

src/com.github.akovac35.Logging.Serilog/com.github.akovac35.Logging.Serilog.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
<PropertyGroup>
44
<Description>Helpful resources for .NET Core and ASP.NET Core logging using various logger frameworks and Microsoft.Extensions.Logging.ILogger interface.</Description>
5-
<VersionPrefix>1.1.2</VersionPrefix>
5+
<Version>1.2.0</Version>
66
<Authors>Aleksander Kovač</Authors>
7-
<TargetFrameworks>netstandard2.1</TargetFrameworks>
7+
<TargetFrameworks>net5.0</TargetFrameworks>
88
<PackageTags>logging;serilog;nlog;correlation</PackageTags>
99
<RepositoryUrl>https://github.com/akovac35/Logging</RepositoryUrl>
1010
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
1111
<IncludeSymbols>true</IncludeSymbols>
1212
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1313
<PackageIcon>.NET_Core_Logo.png</PackageIcon>
1414
<RepositoryType>git</RepositoryType>
15-
<PackageReleaseNotes>Updated Logging version.</PackageReleaseNotes>
15+
<PackageReleaseNotes>Bumped references and framework version.</PackageReleaseNotes>
1616

1717
<Nullable>enable</Nullable>
1818
<LangVersion>latest</LangVersion>
@@ -22,9 +22,9 @@
2222

2323
<ItemGroup>
2424

25-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.5" />
26-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.5" />
27-
<PackageReference Include="Serilog" Version="2.9.0" />
25+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
26+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
27+
<PackageReference Include="Serilog" Version="2.10.0" />
2828
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
2929
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
3030
</ItemGroup>

src/com.github.akovac35.Logging.Testing.Tests/com.github.akovac35.Logging.Testing.Tests.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net5.0</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.5" />
11-
<PackageReference Include="nunit" Version="3.12.0" />
12-
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1">
10+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
11+
<PackageReference Include="nunit" Version="3.13.2" />
12+
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0">
1313
<PrivateAssets>all</PrivateAssets>
1414
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1515
</PackageReference>
16-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
16+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
1717
</ItemGroup>
1818

1919
<ItemGroup>

src/com.github.akovac35.Logging.Testing/IServiceCollectionExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// Authors:
55
// Aleksander Kovač
66

7+
using com.github.akovac35.Logging.Correlation;
78
using Microsoft.Extensions.DependencyInjection;
89
using Microsoft.Extensions.DependencyInjection.Extensions;
910
using Microsoft.Extensions.Logging;
@@ -36,6 +37,7 @@ public static IServiceCollection AddTestLogger(this IServiceCollection services,
3637
return fact.GetRequiredService<TestLoggerFactory>();
3738
});
3839
services.TryAddSingleton(typeof(ILogger<>), typeof(TestLogger<>));
40+
services.TryAddScoped<CorrelationProviderAccessor, TestCorrelationProviderAccessor>();
3941

4042
return services;
4143
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// License:
2+
// Apache License Version 2.0, January 2004
3+
4+
// Authors:
5+
// Aleksander Kovač
6+
7+
using com.github.akovac35.Logging.Correlation;
8+
9+
namespace com.github.akovac35.Logging.Testing
10+
{
11+
public class TestCorrelationProviderAccessor : CorrelationProviderAccessor
12+
{
13+
public override ICorrelationProvider Current => _correlationProviderInstance;
14+
15+
private CorrelationProvider _correlationProviderInstance = new CorrelationProvider();
16+
17+
}
18+
}

src/com.github.akovac35.Logging.Testing/com.github.akovac35.Logging.Testing.csproj

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,33 @@
22

33
<PropertyGroup>
44
<Description>Helpful resources for .NET Core and ASP.NET Core logging using various logger frameworks and Microsoft.Extensions.Logging.ILogger interface.</Description>
5-
<VersionPrefix>1.1.2</VersionPrefix>
5+
<Version>1.2.0</Version>
66
<Authors>Aleksander Kovač</Authors>
7-
<TargetFrameworks>netstandard2.1</TargetFrameworks>
7+
<TargetFrameworks>net5.0</TargetFrameworks>
88
<PackageTags>logging;serilog;nlog;correlation</PackageTags>
99
<RepositoryUrl>https://github.com/akovac35/Logging</RepositoryUrl>
1010
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
1111
<IncludeSymbols>true</IncludeSymbols>
1212
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1313
<PackageIcon>.NET_Core_Logo.png</PackageIcon>
1414
<RepositoryType>git</RepositoryType>
15-
<PackageReleaseNotes>Updated Logging version.</PackageReleaseNotes>
15+
<PackageReleaseNotes>Bumped references and framework version.</PackageReleaseNotes>
1616

1717
<LangVersion>latest</LangVersion>
1818

1919
<IsPackable>true</IsPackable>
2020
</PropertyGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.5" />
24-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.5" />
23+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
24+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
2525
<PackageReference Include="System.Collections.Concurrent" Version="4.3.0" />
2626

2727
<None Include="../../Resources/.NET_Core_Logo.png" Pack="true" PackagePath="" />
2828
</ItemGroup>
2929

30+
<ItemGroup>
31+
<ProjectReference Include="..\com.github.akovac35.Logging\com.github.akovac35.Logging.csproj" />
32+
</ItemGroup>
33+
3034
</Project>

src/com.github.akovac35.Logging/ILoggerExtensions.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ public static void Here(this ILogger logger, Action<ILogger> logAction, [CallerM
4747
}
4848

4949

50-
public static void Entering(this ILogger logger, params object[] args)
50+
public static void Entering(this ILogger logger, params object?[] args)
5151
{
5252
try
5353
{
5454
if (logger.IsEnabled(LogLevel.Trace))
5555
{
5656
// new object[] { args } is required to log all args items and not just the first one
5757
// https://stackoverflow.com/questions/40885239/using-an-array-as-argument-for-string-format
58-
logger.LogTrace("Entering: {@0}", new object[] { args });
58+
logger.LogTrace("Entering: {@0}", new object?[] { args });
5959
}
6060
}
6161
catch (Exception ex)
@@ -64,13 +64,13 @@ public static void Entering(this ILogger logger, params object[] args)
6464
}
6565
}
6666

67-
public static void EnteringSimpleFormat(this ILogger logger, params object[] args)
67+
public static void EnteringSimpleFormat(this ILogger logger, params object?[] args)
6868
{
6969
if (logger.IsEnabled(LogLevel.Trace))
7070
{
7171
// new object[] { args } is required to log all args items and not just the first one
7272
// https://stackoverflow.com/questions/40885239/using-an-array-as-argument-for-string-format
73-
logger.LogTrace("Entering: {0}", new object[] { args });
73+
logger.LogTrace("Entering: {0}", new object?[] { args });
7474
}
7575
}
7676

@@ -79,15 +79,15 @@ public static void Entering(this ILogger logger)
7979
logger.LogTrace("Entering");
8080
}
8181

82-
public static void Entering(this ILogger logger, LogLevel level, params object[] args)
82+
public static void Entering(this ILogger logger, LogLevel level, params object?[] args)
8383
{
8484
try
8585
{
8686
if (logger.IsEnabled(level))
8787
{
8888
// new object[] { args } is required to log all args items and not just the first one
8989
// https://stackoverflow.com/questions/40885239/using-an-array-as-argument-for-string-format
90-
logger.Log(level, "Entering: {@0}", new object[] { args });
90+
logger.Log(level, "Entering: {@0}", new object?[] { args });
9191
}
9292
}
9393
catch (Exception ex)
@@ -96,25 +96,25 @@ public static void Entering(this ILogger logger, LogLevel level, params object[]
9696
}
9797
}
9898

99-
public static void EnteringSimpleFormat(this ILogger logger, LogLevel level, params object[] args)
99+
public static void EnteringSimpleFormat(this ILogger logger, LogLevel level, params object?[] args)
100100
{
101101
if (logger.IsEnabled(level))
102102
{
103103
// new object[] { args } is required to log all args items and not just the first one
104104
// https://stackoverflow.com/questions/40885239/using-an-array-as-argument-for-string-format
105-
logger.Log(level, "Entering: {0}", new object[] { args });
105+
logger.Log(level, "Entering: {0}", new object?[] { args });
106106
}
107107
}
108108

109-
public static void Exiting(this ILogger logger, params object[] args)
109+
public static void Exiting(this ILogger logger, params object?[] args)
110110
{
111111
try
112112
{
113113
if (logger.IsEnabled(LogLevel.Trace))
114114
{
115115
// new object[] { args } is required to log all args items and not just the first one
116116
// https://stackoverflow.com/questions/40885239/using-an-array-as-argument-for-string-format
117-
logger.LogTrace("Exiting: {@0}", new object[] { args });
117+
logger.LogTrace("Exiting: {@0}", new object?[] { args });
118118
}
119119
}
120120
catch (Exception ex)
@@ -123,13 +123,13 @@ public static void Exiting(this ILogger logger, params object[] args)
123123
}
124124
}
125125

126-
public static void ExitingSimpleFormat(this ILogger logger, params object[] args)
126+
public static void ExitingSimpleFormat(this ILogger logger, params object?[] args)
127127
{
128128
if (logger.IsEnabled(LogLevel.Trace))
129129
{
130130
// new object[] { args } is required to log all args items and not just the first one
131131
// https://stackoverflow.com/questions/40885239/using-an-array-as-argument-for-string-format
132-
logger.LogTrace("Exiting: {0}", new object[] { args });
132+
logger.LogTrace("Exiting: {0}", new object?[] { args });
133133
}
134134
}
135135

@@ -138,15 +138,15 @@ public static void Exiting(this ILogger logger)
138138
logger.LogTrace("Exiting");
139139
}
140140

141-
public static void Exiting(this ILogger logger, LogLevel level, params object[] args)
141+
public static void Exiting(this ILogger logger, LogLevel level, params object?[] args)
142142
{
143143
try
144144
{
145145
if (logger.IsEnabled(level))
146146
{
147147
// new object[] { args } is required to log all args items and not just the first one
148148
// https://stackoverflow.com/questions/40885239/using-an-array-as-argument-for-string-format
149-
logger.Log(level, "Exiting: {@0}", new object[] { args });
149+
logger.Log(level, "Exiting: {@0}", new object?[] { args });
150150
}
151151
}
152152
catch (Exception ex)
@@ -155,13 +155,13 @@ public static void Exiting(this ILogger logger, LogLevel level, params object[]
155155
}
156156
}
157157

158-
public static void ExitingSimpleFormat(this ILogger logger, LogLevel level, params object[] args)
158+
public static void ExitingSimpleFormat(this ILogger logger, LogLevel level, params object?[] args)
159159
{
160160
if (logger.IsEnabled(level))
161161
{
162162
// new object[] { args } is required to log all args items and not just the first one
163163
// https://stackoverflow.com/questions/40885239/using-an-array-as-argument-for-string-format
164-
logger.Log(level, "Exiting: {0}", new object[] { args });
164+
logger.Log(level, "Exiting: {0}", new object?[] { args });
165165
}
166166
}
167167

src/com.github.akovac35.Logging/com.github.akovac35.Logging.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
<PropertyGroup>
44
<Description>Helpful resources for .NET Core and ASP.NET Core logging using various logger frameworks and Microsoft.Extensions.Logging.ILogger interface.</Description>
5-
<VersionPrefix>1.1.2</VersionPrefix>
5+
<Version>1.2.0</Version>
66
<Authors>Aleksander Kovač</Authors>
7-
<TargetFrameworks>netstandard2.1</TargetFrameworks>
7+
<TargetFrameworks>net5.0</TargetFrameworks>
88
<PackageTags>logging;serilog;nlog;correlation</PackageTags>
99
<RepositoryUrl>https://github.com/akovac35/Logging</RepositoryUrl>
1010
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
1111
<IncludeSymbols>true</IncludeSymbols>
1212
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1313
<PackageIcon>.NET_Core_Logo.png</PackageIcon>
1414
<RepositoryType>git</RepositoryType>
15-
<PackageReleaseNotes>Made the Current property of CorrelationProviderAccessor virtual.</PackageReleaseNotes>
15+
<PackageReleaseNotes>Bumped references and framework version. Updated nulabillity for ILogger extensions.</PackageReleaseNotes>
1616

1717
<Nullable>enable</Nullable>
1818
<LangVersion>latest</LangVersion>
@@ -26,7 +26,7 @@
2626
</ItemGroup>
2727

2828
<ItemGroup>
29-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.5" />
29+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
3030
</ItemGroup>
3131

3232
</Project>

0 commit comments

Comments
 (0)