Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
marcsauter committed Dec 24, 2024
1 parent 83bdf35 commit 3fac5f6
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions eventhandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package profiler

import (
"log/slog"
"os"
)

// EventType represents the event type
type EventType int

// Event types
const (
DebugEvent = iota
InfoEvent
ErrorEvent
)

// EventHandler function to handle log events
type EventHandler func(t EventType, v string, args ...any)

func DefaultEventHandler() EventHandler {
l := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
Level: slog.LevelDebug,
}))

return func(eventType EventType, msg string, args ...any) {
switch eventType {
case DebugEvent:
l.Debug(msg, args...)
case ErrorEvent:
l.Error(msg, args...)
default:
l.Info(msg, args...)
}
}
}

0 comments on commit 3fac5f6

Please sign in to comment.