From 114c7101d6565a985686ec62edaafde6701e0da0 Mon Sep 17 00:00:00 2001 From: xuu Date: Sat, 7 Oct 2023 17:57:09 -0600 Subject: [PATCH] fix: add debug levels --- cmd/ev/main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/ev/main.go b/cmd/ev/main.go index b1117e8..27f56d4 100644 --- a/cmd/ev/main.go +++ b/cmd/ev/main.go @@ -4,10 +4,13 @@ import ( "context" "errors" "log" + "log/slog" "net/http" "os" "os/signal" + "strconv" + "go.sour.is/pkg/env" "go.sour.is/pkg/lg" "go.sour.is/pkg/service" ) @@ -27,6 +30,13 @@ func main() { } } func run(ctx context.Context) error { + // TODO: make this configurable. + level := slog.LevelError + if ok, _ := strconv.ParseBool(env.Default("LOG_DEBUG", "FALSE")); ok { + level = slog.LevelDebug + } + slog.SetDefault(slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: level}))) + svc := &service.Harness{} ctx, stop := lg.Init(ctx, appName) svc.OnStop(stop)