Skip to content

Commit

Permalink
style: 💄 fix code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdihadeli committed Sep 26, 2024
1 parent 53f28e0 commit 61a9920
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions src/Shared/Logging/Extensions/DependencyInjectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public static WebApplicationBuilder AddCustomSerilog(
// https://github.com/serilog/serilog-settings-configuration
loggerConfiguration.ReadFrom.Configuration(
builder.Configuration,
new ConfigurationReaderOptions {SectionName = nameof(SerilogOptions)});
new ConfigurationReaderOptions { SectionName = nameof(SerilogOptions) }
);

extraConfigure?.Invoke(loggerConfiguration);

Expand All @@ -56,16 +57,16 @@ public static WebApplicationBuilder AddCustomSerilog(
.Enrich.WithExceptionDetails(
new DestructuringOptionsBuilder()
.WithDefaultDestructurers()
.WithDestructurers(new[] {new DbUpdateExceptionDestructurer()}));

.WithDestructurers(new[] { new DbUpdateExceptionDestructurer() })
);

if (serilogOptions.UseConsole)
{
// https://github.com/serilog/serilog-sinks-async
// https://github.com/lucadecamillis/serilog-sinks-spectre
loggerConfiguration.WriteTo.Async(
writeTo =>
writeTo.Spectre(outputTemplate: serilogOptions.LogTemplate));
loggerConfiguration.WriteTo.Async(writeTo =>
writeTo.Spectre(outputTemplate: serilogOptions.LogTemplate)
);
}

// https://github.com/serilog/serilog-sinks-async
Expand All @@ -74,7 +75,7 @@ public static WebApplicationBuilder AddCustomSerilog(
// elasticsearch sink internally is async
// https://www.nuget.org/packages/Elastic.Serilog.Sinks
loggerConfiguration.WriteTo.Elasticsearch(
new[] {new Uri(serilogOptions.ElasticSearchUrl),},
new[] { new Uri(serilogOptions.ElasticSearchUrl) },
opts =>
{
opts.DataStream = new DataStreamName(
Expand All @@ -84,17 +85,17 @@ public static WebApplicationBuilder AddCustomSerilog(
builder.Environment.EnvironmentName
}-{
DateTime.Now
:yyyy-MM}");
:yyyy-MM}"
);

opts.BootstrapMethod = BootstrapMethod.Failure;

opts.ConfigureChannel = channelOpts =>
{
channelOpts.BufferOptions =
new BufferOptions
{ExportMaxConcurrency = 10};
};
});
{
channelOpts.BufferOptions = new BufferOptions { ExportMaxConcurrency = 10 };
};
}
);
}

// https://github.com/serilog-contrib/serilog-sinks-grafana-loki
Expand All @@ -104,9 +105,10 @@ public static WebApplicationBuilder AddCustomSerilog(
serilogOptions.GrafanaLokiUrl,
new[]
{
new LokiLabel {Key = "service", Value = "food-delivery"},
new LokiLabel { Key = "service", Value = "food-delivery" },
},
["app"]);
["app"]
);
}

if (!string.IsNullOrEmpty(serilogOptions.SeqUrl))
Expand All @@ -124,15 +126,17 @@ public static WebApplicationBuilder AddCustomSerilog(

if (!string.IsNullOrEmpty(serilogOptions.LogPath))
{
loggerConfiguration.WriteTo.Async(
writeTo =>
writeTo.File(
serilogOptions.LogPath,
outputTemplate: serilogOptions.LogTemplate,
rollingInterval: RollingInterval.Day,
rollOnFileSizeLimit: true));
loggerConfiguration.WriteTo.Async(writeTo =>
writeTo.File(
serilogOptions.LogPath,
outputTemplate: serilogOptions.LogTemplate,
rollingInterval: RollingInterval.Day,
rollOnFileSizeLimit: true
)
);
}
});
}
);

return builder;
}
Expand Down

0 comments on commit 61a9920

Please sign in to comment.