Brijesh's Git Server — argus-demo @ f2338785f527e2bc8047a3a3236eedbbc838eca9

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
commit

f2338785f527e2bc8047a3a3236eedbbc838eca9

parent

0463e833db032e9940eaa0f69a9b425a1f08df44

1 files changed, 12 insertions(+), 4 deletions(-)

jump to
M main.gomain.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") }