Add persistent event ID to log context

This commit is contained in:
Ske 2020-08-27 14:40:49 +02:00
parent ca4ffdb803
commit e556cc71fa

View File

@ -102,12 +102,13 @@ namespace PluralKit.Bot
async Task HandleEventInner() async Task HandleEventInner()
{ {
using var _ = LogContext.PushProperty("EventId", Guid.NewGuid());
// Mainly for testing ELK volume atm, no-op unless Elastic is configured // Mainly for testing ELK volume atm, no-op unless Elastic is configured
if (evt is MessageCreateEventArgs mc) if (evt is MessageCreateEventArgs mc)
using (LogContext.PushProperty("Elastic", "yes?")) using (LogContext.PushProperty("Elastic", "yes?"))
_logger.Information("Received event {@Event}", new _logger.Information("Received event {@Event}", new
{ {
Id = Guid.NewGuid(),
Type = mc.GetType().Name.Replace("EventArgs", ""), Type = mc.GetType().Name.Replace("EventArgs", ""),
MessageId = mc.Message.Id, MessageId = mc.Message.Id,
ChannelId = mc.Channel.Id, ChannelId = mc.Channel.Id,