From 20be557b7bc3d7ada78411b7b279c9f7580d0bc7 Mon Sep 17 00:00:00 2001 From: tjpcc Date: Mon, 9 Oct 2023 08:58:31 -0600 Subject: logging.Base() Allow users to get access to the base logger *before* it is wrapped with the various levels. This provides a single override point to filter or redirect all logging. --- examples/cgi/main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'examples/cgi') diff --git a/examples/cgi/main.go b/examples/cgi/main.go index 4d48422..587c874 100644 --- a/examples/cgi/main.go +++ b/examples/cgi/main.go @@ -7,6 +7,7 @@ import ( "os/signal" "syscall" + "github.com/go-kit/log/level" "tildegit.org/tjp/sliderule/contrib/cgi" "tildegit.org/tjp/sliderule/gemini" "tildegit.org/tjp/sliderule/logging" @@ -25,17 +26,17 @@ func main() { // make use of a CGI request handler cgiHandler := cgi.GeminiCGIDirectory("./cgi-bin", "/cgi-bin") - _, infoLog, _, errLog := logging.DefaultLoggers() + baseLog := logging.Base() // add stdout logging to the request handler - handler := logging.LogRequests(infoLog)(cgiHandler) + handler := logging.LogRequests(level.Info(baseLog))(cgiHandler) // set up signals to trigger graceful shutdown ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGHUP) defer stop() // run the server - server, err := gemini.NewServer(ctx, "localhost", "tcp4", ":1965", handler, errLog, tlsconf) + server, err := gemini.NewServer(ctx, "localhost", "tcp4", ":1965", handler, baseLog, tlsconf) if err != nil { log.Fatal(err) } -- cgit v1.2.3