-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6382e99
commit f047798
Showing
87 changed files
with
126 additions
and
2,225 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,18 @@ | ||
using DragonSpark.Model.Commands; | ||
using Microsoft.Extensions.Logging; | ||
using Serilog; | ||
using ILogger = Serilog.ILogger; | ||
|
||
namespace DragonSpark.Diagnostics; | ||
|
||
sealed class AddSerilog : ICommand<ILoggingBuilder> | ||
{ | ||
readonly ILogger _logger; | ||
|
||
public AddSerilog(ILogger logger) => _logger = logger; | ||
|
||
public void Execute(ILoggingBuilder parameter) | ||
{ | ||
parameter.AddSerilog(_logger, true); | ||
} | ||
} |
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,19 @@ | ||
using DragonSpark.Model.Commands; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Serilog; | ||
using System; | ||
|
||
namespace DragonSpark.Diagnostics; | ||
|
||
sealed class ConfigureSerilog : ICommand<IServiceCollection> | ||
{ | ||
readonly Func<IServiceCollection, ILogger> _logger; | ||
|
||
public ConfigureSerilog(Func<IServiceCollection, ILogger> logger) => _logger = logger; | ||
|
||
public void Execute(IServiceCollection parameter) | ||
{ | ||
var logger = _logger(parameter); | ||
parameter.AddLogging(new AddSerilog(logger).Execute); | ||
} | ||
} |
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,32 @@ | ||
using DragonSpark.Model.Selection; | ||
using Microsoft.Extensions.Configuration; | ||
using Serilog; | ||
using Serilog.Enrichers.Correlation; | ||
|
||
namespace DragonSpark.Diagnostics; | ||
|
||
sealed class CreateConfiguration : ISelect<IConfiguration, LoggerConfiguration> | ||
{ | ||
public static CreateConfiguration Default { get; } = new(); | ||
|
||
CreateConfiguration() {} | ||
|
||
public LoggerConfiguration Get(IConfiguration parameter) | ||
{ | ||
var instance = new LoggerConfiguration().Enrich.WithDemystifiedStackTraces() | ||
.Enrich.WithEnvironmentName() | ||
.Enrich.WithEnvironmentUserName() | ||
.Enrich.FromLogContext() | ||
.Enrich.WithProcessId() | ||
.Enrich.WithProcessName() | ||
.Enrich.WithMemoryUsage() | ||
.Enrich.WithThreadId() | ||
.Enrich.WithThreadName() | ||
.Enrich.WithCorrelationId() | ||
.Enrich.WithEnvironmentUserName() | ||
.Enrich; | ||
var result = EnvironmentLoggerConfigurationExtensions.WithMachineName(instance) | ||
.ReadFrom.Configuration(parameter); | ||
return result; | ||
} | ||
} |
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,13 @@ | ||
using DragonSpark.Model.Selection; | ||
using Serilog; | ||
|
||
namespace DragonSpark.Diagnostics; | ||
|
||
sealed class CreateLogger : ISelect<LoggerConfiguration, ILogger> | ||
{ | ||
public static CreateLogger Default { get; } = new(); | ||
|
||
CreateLogger() {} | ||
|
||
public ILogger Get(LoggerConfiguration parameter) => parameter.CreateLogger(); | ||
} |
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,17 @@ | ||
using DragonSpark.Compose; | ||
using DragonSpark.Composition; | ||
using DragonSpark.Model.Selection; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Serilog; | ||
|
||
namespace DragonSpark.Diagnostics; | ||
|
||
sealed class DefaultLogger : Select<IServiceCollection, ILogger> | ||
{ | ||
public static DefaultLogger Default { get; } = new(); | ||
|
||
DefaultLogger() : base(Start.A.Selection<IServiceCollection>() | ||
.By.Calling(x => x.Configuration()) | ||
.Select(CreateConfiguration.Default) | ||
.Select(CreateLogger.Default)) {} | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,15 @@ | ||
using DragonSpark.Composition.Compose; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System; | ||
using ILogger = Serilog.ILogger; | ||
|
||
namespace DragonSpark.Diagnostics; | ||
|
||
public static class Extensions | ||
{ | ||
public static BuildHostContext WithSerilog(this BuildHostContext @this) | ||
=> @this.WithSerilog(DefaultLogger.Default.Get); | ||
|
||
public static BuildHostContext WithSerilog(this BuildHostContext @this, Func<IServiceCollection, ILogger> logger) | ||
=> @this.Configure(new ConfigureSerilog(logger)); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
DragonSpark.Diagnostics/Logging/ApplyProjectionsCommand.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.