certwarden-deploy/internal/logger/logger.go

28 lines
429 B
Go
Raw Normal View History

2024-06-28 15:28:54 +02:00
package logger
import (
"log/slog"
"os"
2024-06-30 08:55:07 +02:00
"code.lila.network/adoralaura/certwarden-deploy/internal/config"
2024-06-28 15:28:54 +02:00
)
func InitializeLogger() {
2024-06-30 08:55:07 +02:00
logLevel := slog.LevelInfo
if config.VerboseLogging {
logLevel = slog.LevelDebug
}
if config.QuietLogging {
logLevel = slog.LevelError
}
2024-06-28 15:28:54 +02:00
opts := &slog.HandlerOptions{
2024-06-30 08:55:07 +02:00
Level: logLevel,
2024-06-28 15:28:54 +02:00
}
handler := slog.NewTextHandler(os.Stdout, opts)
slog.SetDefault(slog.New(handler))
}