21 lines
339 B
Go
21 lines
339 B
Go
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))
|
|
}
|