feat: tell client to send logs to server immediately in case of crash
Brijesh Wawdhane ops@brijesh.dev
Sat, 28 Dec 2024 16:33:12 +0530
1 files changed,
12 insertions(+),
4 deletions(-)
jump to
M
main.go
→
main.go
@@ -17,8 +17,16 @@
argusHandler := argus_client.NewArgusHandler(client) logger := slog.New(argusHandler) - logger.Info("Info Log using slog handler") - logger.Error("Error Log using slog handler") - logger.Debug("Debug Log using slog handler") - logger.Warn("Warn Log using slog handler") + defer func() { + if r := recover(); r != nil { + argusHandler.Flush() + } + }() + + logger.Info("Info Log using slog handler using buffers") + logger.Error("Error Log using slog handler using buffers") + logger.Debug("Debug Log using slog handler using buffers") + logger.Warn("Warn Log using slog handler using buffers") + + panic("simulated panic") }