Brijesh's Git Server — argus-demo @ main

main.go (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
package main

import (
	"log/slog"
	"time"

	"github.com/wbrijesh/argus_client"
)

func main() {
	client := argus_client.NewClient(
		argus_client.ClientConfig{
			ApiKey:  "argus_jW35MW2m-dNdtSbhFVSrudlSIpQCA99apo_2mRvdbjU",
			BaseUrl: "http://localhost:8080",
		},
	)

	argusHandler := argus_client.NewArgusHandler(client)
	logger := slog.New(argusHandler)

	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")

	time.Sleep(3 * time.Second)

	logger.Debug("Debug Log using slog handler using buffers")
	logger.Warn("Warn Log using slog handler using buffers")

	panic("simulated panic")
}