feat: add git commit hash to Serilog context
This commit is contained in:
		@@ -115,7 +115,7 @@ public class Startup
 | 
				
			|||||||
        // add X-PluralKit-Version header
 | 
					        // add X-PluralKit-Version header
 | 
				
			||||||
        app.Use((ctx, next) =>
 | 
					        app.Use((ctx, next) =>
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            ctx.Response.Headers.Add("X-PluralKit-Version", BuildInfoService.Version);
 | 
					            ctx.Response.Headers.Add("X-PluralKit-Version", BuildInfoService.FullVersion);
 | 
				
			||||||
            return next();
 | 
					            return next();
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,20 +16,20 @@ namespace PluralKit.Bot;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public class Init
 | 
					public class Init
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    private static Task Main(string[] args)
 | 
					    private static async Task Main(string[] args)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        // Load configuration and run global init stuff
 | 
					        // Load configuration and run global init stuff
 | 
				
			||||||
        var config = InitUtils.BuildConfiguration(args).Build();
 | 
					        var config = InitUtils.BuildConfiguration(args).Build();
 | 
				
			||||||
        InitUtils.InitStatic();
 | 
					        InitUtils.InitStatic();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // init version service
 | 
				
			||||||
 | 
					        await BuildInfoService.LoadVersion();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Set up DI container and modules
 | 
					        // Set up DI container and modules
 | 
				
			||||||
        var services = BuildContainer(config);
 | 
					        var services = BuildContainer(config);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return RunWrapper(services, async ct =>
 | 
					        await RunWrapper(services, async ct =>
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            // init version service
 | 
					 | 
				
			||||||
            await BuildInfoService.LoadVersion();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            var logger = services.Resolve<ILogger>().ForContext<Init>();
 | 
					            var logger = services.Resolve<ILogger>().ForContext<Init>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Initialize Sentry SDK, and make sure it gets dropped at the end
 | 
					            // Initialize Sentry SDK, and make sure it gets dropped at the end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -52,6 +52,7 @@ public class LoggingModule: Module
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        var logCfg = _cfg
 | 
					        var logCfg = _cfg
 | 
				
			||||||
            .Enrich.FromLogContext()
 | 
					            .Enrich.FromLogContext()
 | 
				
			||||||
 | 
					            .Enrich.WithProperty("GitCommitHash", BuildInfoService.FullVersion)
 | 
				
			||||||
            .ConfigureForNodaTime(DateTimeZoneProviders.Tzdb)
 | 
					            .ConfigureForNodaTime(DateTimeZoneProviders.Tzdb)
 | 
				
			||||||
            .Enrich.WithProperty("Component", _component)
 | 
					            .Enrich.WithProperty("Component", _component)
 | 
				
			||||||
            .MinimumLevel.Is(config.ConsoleLogLevel)
 | 
					            .MinimumLevel.Is(config.ConsoleLogLevel)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,6 +16,8 @@ internal class Startup
 | 
				
			|||||||
        var config = InitUtils.BuildConfiguration(args).Build();
 | 
					        var config = InitUtils.BuildConfiguration(args).Build();
 | 
				
			||||||
        InitUtils.InitStatic();
 | 
					        InitUtils.InitStatic();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        await BuildInfoService.LoadVersion();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        var services = BuildContainer(config);
 | 
					        var services = BuildContainer(config);
 | 
				
			||||||
        services.Resolve<TaskHandler>().Run();
 | 
					        services.Resolve<TaskHandler>().Run();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user