Files
lambda/internal/config/get_logger.go

24 lines
440 B
Go

package config
import (
"log/slog"
"os"
)
// Returns a structured logger with the appropriate configurations.
func (c Config) GetLogger() *slog.Logger {
// By default, only print out errors.
level := slog.LevelError
// If the user set the output to be "VERBOSE", return the debug logs.
if c.Verbose {
level = slog.LevelInfo
}
return slog.New(
slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
Level: level,
}),
)
}