Added more IHosting support
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Net.Http.Json" Version="10.0.8" />
|
||||
<PackageReference Include="System.Net.Http.Json" Version="10.0.9" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EonaCat.LogStack\EonaCat.LogStack.csproj" />
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OpenTelemetry" Version="1.15.0" />
|
||||
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.15.0" />
|
||||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.15.0" />
|
||||
<PackageReference Include="System.Threading.AccessControl" Version="10.0.3" />
|
||||
<PackageReference Include="OpenTelemetry" Version="1.15.3" />
|
||||
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.15.3" />
|
||||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.15.3" />
|
||||
<PackageReference Include="System.Threading.AccessControl" Version="10.0.9" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<PackageReference Include="Serilog.Sinks.Async" Version="2.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Network" Version="3.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Seq" Version="9.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Seq" Version="9.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -9,6 +9,6 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0" />
|
||||
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
||||
<PackageReference Include="BCrypt.Net-Next" Version="4.2.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Diagnostics.EventLog" Version="10.0.8" />
|
||||
<PackageReference Include="System.Threading.AccessControl" Version="10.0.8" />
|
||||
<PackageReference Include="System.Diagnostics.EventLog" Version="10.0.9" />
|
||||
<PackageReference Include="System.Threading.AccessControl" Version="10.0.9" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -14,7 +14,7 @@ It features a rich fluent API for routing log events to dozens of destinations f
|
||||
<Copyright>EonaCat (Jeroen Saey)</Copyright>
|
||||
<PackageTags>EonaCat;Logger;EonaCatLogStack;Log;Writer;Flows;LogStack;Memory;Speed;Jeroen;Saey</PackageTags>
|
||||
<PackageIconUrl />
|
||||
<FileVersion>0.0.7</FileVersion>
|
||||
<FileVersion>0.0.8</FileVersion>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
@@ -25,7 +25,7 @@ It features a rich fluent API for routing log events to dozens of destinations f
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<EVRevisionFormat>0.0.7+{chash:10}.{c:ymd}</EVRevisionFormat>
|
||||
<EVRevisionFormat>0.0.8+{chash:10}.{c:ymd}</EVRevisionFormat>
|
||||
<EVDefault>true</EVDefault>
|
||||
<EVInfo>true</EVInfo>
|
||||
<EVTagMatch>v[0-9]*</EVTagMatch>
|
||||
@@ -36,10 +36,11 @@ It features a rich fluent API for routing log events to dozens of destinations f
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>0.0.7</Version>
|
||||
<Version>0.0.8</Version>
|
||||
<PackageId>EonaCat.LogStack</PackageId>
|
||||
<Product>EonaCat.LogStack</Product>
|
||||
<RepositoryUrl>https://git.saey.me/EonaCat/EonaCat.LogStack</RepositoryUrl>
|
||||
<UserSecretsId>09d73ec1-ee68-42bb-b2bd-b0e31b635098</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="EVPack" BeforeTargets="Pack">
|
||||
@@ -73,11 +74,12 @@ It features a rich fluent API for routing log events to dozens of destinations f
|
||||
</PackageReference>
|
||||
<PackageReference Include="EonaCat.Versioning.Helpers" Version="1.5.0" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.8" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.8" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.8" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.9" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.9" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.9" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.9" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.4" />
|
||||
<PackageReference Include="System.Threading.Channels" Version="10.0.8" />
|
||||
<PackageReference Include="System.Threading.Channels" Version="10.0.9" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Update="LICENSE.md">
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
|
||||
namespace EonaCat.LogStack.Logging;
|
||||
|
||||
public sealed class EonaCatLoggerProvider : ILoggerProvider
|
||||
{
|
||||
private readonly EonaCatLogStack _logStack;
|
||||
public EonaCatLoggerProvider(EonaCatLogStack logStack)=>_logStack=logStack;
|
||||
public Microsoft.Extensions.Logging.ILogger CreateLogger(string categoryName) => new CategoryLogger(categoryName,_logStack);
|
||||
public void Dispose(){}
|
||||
}
|
||||
|
||||
internal sealed class CategoryLogger : Microsoft.Extensions.Logging.ILogger
|
||||
{
|
||||
private readonly string _category;
|
||||
private readonly EonaCatLogStack _stack;
|
||||
public CategoryLogger(string category,EonaCatLogStack stack){_category=category;_stack=stack;}
|
||||
public IDisposable BeginScope<TState>(TState state) where TState:notnull => NullScope.Instance;
|
||||
public bool IsEnabled(LogLevel logLevel)=>true;
|
||||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter){var msg=$"[{_category}] {formatter(state,exception)}"; _stack.Log(msg);}
|
||||
}
|
||||
internal sealed class NullScope:IDisposable { public static readonly NullScope Instance= new(); public void Dispose(){} }
|
||||
@@ -0,0 +1,14 @@
|
||||
using EonaCat.LogStack.Core;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
|
||||
namespace EonaCat.LogStack.Extensions;
|
||||
|
||||
public static class HostApplicationBuilderExtensions
|
||||
{
|
||||
public static IHostApplicationBuilder AddEonaCatLogging(this IHostApplicationBuilder builder, Action<EonaCatLogStack>? configure=null)
|
||||
{
|
||||
builder.Services.AddEonaCatLogging(configure ?? (_=>{}));
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using EonaCat.LogStack.Logging;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
|
||||
namespace EonaCat.LogStack.Extensions;
|
||||
|
||||
public static class LoggingBuilderExtensions
|
||||
{
|
||||
public static ILoggingBuilder AddEonaCatLogging(this ILoggingBuilder builder, Action<EonaCatLogStack>? configure=null)
|
||||
{
|
||||
var logStack = new EonaCatLogStack();
|
||||
configure?.Invoke(logStack);
|
||||
builder.Services.AddSingleton(logStack);
|
||||
builder.Services.AddSingleton<ILoggerProvider, EonaCatLoggerProvider>();
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user