Skip to content

Commit

Permalink
chore: adds debug flag to scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardosbcabral committed Mar 12, 2024
1 parent acb5e9b commit 9b177f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
16 changes: 14 additions & 2 deletions src/Scaffolding.AspNetCore/Extensions/HostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,19 @@ namespace Microsoft.Extensions.DependencyInjection;

public static class HostBuilderExtensions
{
public static IHostBuilder AddSerilogLogging(this IHostBuilder builder, IScaffoldingConfiguration configuration, string requestKeyHeader = "RequestKey")
/// <summary>
/// Adds serilog logging for the api.
/// </summary>
/// <param name="builder"></param>
/// <param name="configuration"></param>
/// <param name="requestKeyHeader">Header that will be used to set the request key for tracing across requests.</param>
/// <param name="debugAsConsole">Flag that will log json even in development for debugging properties purposes.</param>
/// <returns></returns>
public static IHostBuilder AddSerilogLogging(
this IHostBuilder builder,
IScaffoldingConfiguration configuration,
string requestKeyHeader = "RequestKey",
bool debugAsConsole = false)
{
return builder.UseSerilog((context, loggerCfg) =>
{
Expand All @@ -34,7 +46,7 @@ public static IHostBuilder AddSerilogLogging(this IHostBuilder builder, IScaffol
.Enrich.WithProperty(nameof(applicationSettings.Domain), applicationSettings.Domain)
.Enrich.With(new RemovePropertiesEnricher());
if (!context.HostingEnvironment.IsDevelopment())
if (context.HostingEnvironment.IsDevelopment() || debugAsConsole)
{
loggerCfg
.WriteTo.Console()
Expand Down
6 changes: 0 additions & 6 deletions src/Scaffolding.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Scaffolding.Sample", "Scaff
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Scaffolding.Logging.Serilog", "Scaffolding.Logging.Serilog\Scaffolding.Logging.Serilog.csproj", "{C1E7E180-1222-4F99-98A7-69B0AE2C8CB8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Scaffolding.Shared", "Scaffolding.Shared\Scaffolding.Shared.csproj", "{B52C98FD-6C4E-4B4A-BB19-98D29DE1F9FD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Scaffolding.Configuration", "Scaffolding.Configuration\Scaffolding.Configuration.csproj", "{8AE234D6-D794-4AE5-9C86-2E50FB8132D5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Scaffolding.HealthCheck", "Scaffolding.HealthCheck\Scaffolding.HealthCheck.csproj", "{95758A46-404E-4960-AF40-D3E2127C73CC}"
Expand Down Expand Up @@ -41,10 +39,6 @@ Global
{C1E7E180-1222-4F99-98A7-69B0AE2C8CB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C1E7E180-1222-4F99-98A7-69B0AE2C8CB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C1E7E180-1222-4F99-98A7-69B0AE2C8CB8}.Release|Any CPU.Build.0 = Release|Any CPU
{B52C98FD-6C4E-4B4A-BB19-98D29DE1F9FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B52C98FD-6C4E-4B4A-BB19-98D29DE1F9FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B52C98FD-6C4E-4B4A-BB19-98D29DE1F9FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B52C98FD-6C4E-4B4A-BB19-98D29DE1F9FD}.Release|Any CPU.Build.0 = Release|Any CPU
{8AE234D6-D794-4AE5-9C86-2E50FB8132D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8AE234D6-D794-4AE5-9C86-2E50FB8132D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8AE234D6-D794-4AE5-9C86-2E50FB8132D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down

0 comments on commit 9b177f6

Please sign in to comment.