mailcow-admin-aliases/internal/logging/logger.go

22 lines
339 B
Go
Raw Permalink Normal View History

2024-07-24 17:36:01 +02:00
package logging
import (
"log/slog"
"os"
)
func NewSlogLogger(quiet bool, verbose bool) {
slogLevel := slog.LevelInfo
if quiet {
slogLevel = slog.LevelError
}
if verbose {
slogLevel = slog.LevelDebug
}
handler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slogLevel})
slog.SetDefault(slog.New(handler))
}