Skip to content

Commit

Permalink
Merge pull request #46 from dragonfruitnetwork/cleanup-logging
Browse files Browse the repository at this point in the history
inject logger earlier and use extension method
  • Loading branch information
aspriddell authored Nov 26, 2022
2 parents 145623d + 654733f commit f58c3bc
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions DragonFruit.Sakura/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using MudBlazor.Services;
using Serilog;
using Serilog.Events;
using Serilog.Extensions.Logging;

namespace DragonFruit.Sakura
{
Expand All @@ -35,6 +34,22 @@ public static async Task Main(string[] args)
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

var loggingConfig = new LoggerConfiguration()
.MinimumLevel.Debug()
.Enrich.WithProperty("InstanceId", Guid.NewGuid().ToString("D"))
.WriteTo.BrowserConsole()
.WriteTo.Sentry(o =>
{
var version = Assembly.GetExecutingAssembly().GetName().Version;
o.MaxBreadcrumbs = 50;
o.MinimumEventLevel = LogEventLevel.Error;
o.MinimumBreadcrumbLevel = LogEventLevel.Debug;
o.Release = version?.ToString(version.Build > 0 ? 3 : 2);
o.Dsn = "https://d42ddda84a6f4ffb8d9d66cb7d1a6d9b@o97031.ingest.sentry.io/6542291";
});

builder.Logging.AddSerilog(loggingConfig.CreateLogger(), true);
builder.Services.AddOidcAuthentication(o =>
{
o.ProviderOptions.Authority = "https://id.dragonfruit.network/connect/authorize";
Expand All @@ -61,23 +76,6 @@ public static async Task Main(string[] args)
builder.Services.AddScoped<WikiRenderer>();
builder.Services.AddScoped<ApiClient, SakuraClient>();

var loggingConfig = new LoggerConfiguration()
.MinimumLevel.Debug()
.Enrich.WithProperty("InstanceId", Guid.NewGuid().ToString("D"))
.WriteTo.BrowserConsole()
.WriteTo.Sentry(o =>
{
var version = Assembly.GetExecutingAssembly().GetName().Version;
o.MaxBreadcrumbs = 50;
o.MinimumEventLevel = LogEventLevel.Error;
o.MinimumBreadcrumbLevel = LogEventLevel.Debug;
o.Release = version?.ToString(version.Build > 0 ? 3 : 2);
o.Dsn = "https://d42ddda84a6f4ffb8d9d66cb7d1a6d9b@o97031.ingest.sentry.io/6542291";
});

builder.Logging.AddProvider(new SerilogLoggerProvider(loggingConfig.CreateLogger(), true));

await builder.Build().RunAsync();
}
}
Expand Down

0 comments on commit f58c3bc

Please sign in to comment.