diff options
author | tjpcc <tjp@ctrl-c.club> | 2023-01-23 22:15:16 -0700 |
---|---|---|
committer | tjpcc <tjp@ctrl-c.club> | 2023-01-23 22:15:16 -0700 |
commit | 0480e066a3f1ae97dbab8fcb6303589eb0fa724c (patch) | |
tree | 1aa347eb3691a29987475fcf6049343aa227a365 /examples | |
parent | df57a12539030297b3254bc81f5696691cbc9c6f (diff) |
logging library up to top level
Diffstat (limited to 'examples')
-rw-r--r-- | examples/cgi/main.go | 8 | ||||
-rw-r--r-- | examples/cowsay/main.go | 8 | ||||
-rw-r--r-- | examples/fileserver/main.go | 9 | ||||
-rw-r--r-- | examples/inspectls/main.go | 8 |
4 files changed, 21 insertions, 12 deletions
diff --git a/examples/cgi/main.go b/examples/cgi/main.go index 3dfec29..6036454 100644 --- a/examples/cgi/main.go +++ b/examples/cgi/main.go @@ -8,8 +8,8 @@ import ( "syscall" "tildegit.org/tjp/gus/contrib/cgi" - guslog "tildegit.org/tjp/gus/contrib/log" "tildegit.org/tjp/gus/gemini" + "tildegit.org/tjp/gus/logging" ) func main() { @@ -25,15 +25,17 @@ func main() { // make use of a CGI request handler cgiHandler := cgi.CGIDirectory("/cgi-bin", "./cgi-bin") + _, infoLog, _, errLog := logging.DefaultLoggers() + // add stdout logging to the request handler - handler := guslog.Requests(os.Stdout, nil)(cgiHandler) + handler := logging.LogRequests(infoLog)(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, tlsconf, "tcp4", ":1965", handler) + server, err := gemini.NewServer(ctx, errLog, tlsconf, "tcp4", ":1965", handler) if err != nil { log.Fatal(err) } diff --git a/examples/cowsay/main.go b/examples/cowsay/main.go index fc5e89f..b239019 100644 --- a/examples/cowsay/main.go +++ b/examples/cowsay/main.go @@ -9,8 +9,8 @@ import ( "os/exec" "tildegit.org/tjp/gus" - guslog "tildegit.org/tjp/gus/contrib/log" "tildegit.org/tjp/gus/gemini" + "tildegit.org/tjp/gus/logging" ) func main() { @@ -23,11 +23,13 @@ func main() { log.Fatal(err) } + _, infoLog, _, errLog := logging.DefaultLoggers() + // add request logging to the request handler - handler := guslog.Requests(os.Stdout, nil)(cowsayHandler) + handler := logging.LogRequests(infoLog)(cowsayHandler) // run the server - server, err := gemini.NewServer(context.Background(), tlsconf, "tcp4", ":1965", handler) + server, err := gemini.NewServer(context.Background(), errLog, tlsconf, "tcp4", ":1965", handler) if err != nil { log.Fatal(err) } diff --git a/examples/fileserver/main.go b/examples/fileserver/main.go index 35c8708..e70974f 100644 --- a/examples/fileserver/main.go +++ b/examples/fileserver/main.go @@ -7,8 +7,8 @@ import ( "tildegit.org/tjp/gus" "tildegit.org/tjp/gus/contrib/fs" - guslog "tildegit.org/tjp/gus/contrib/log" "tildegit.org/tjp/gus/gemini" + "tildegit.org/tjp/gus/logging" ) func main() { @@ -32,11 +32,14 @@ func main() { // finally, try to find a file at the request path and respond with that fs.FileHandler(fileSystem), ) + + _, infoLog, _, errLog := logging.DefaultLoggers() + // add request logging to stdout - handler = guslog.Requests(os.Stdout, nil)(handler) + handler = logging.LogRequests(infoLog)(handler) // run the server - server, err := gemini.NewServer(context.Background(), tlsconf, "tcp4", ":1965", handler) + server, err := gemini.NewServer(context.Background(), errLog, tlsconf, "tcp4", ":1965", handler) if err != nil { log.Fatal(err) } diff --git a/examples/inspectls/main.go b/examples/inspectls/main.go index 65c5229..5022888 100644 --- a/examples/inspectls/main.go +++ b/examples/inspectls/main.go @@ -13,8 +13,8 @@ import ( "strings" "tildegit.org/tjp/gus" - guslog "tildegit.org/tjp/gus/contrib/log" "tildegit.org/tjp/gus/gemini" + "tildegit.org/tjp/gus/logging" ) func main() { @@ -27,11 +27,13 @@ func main() { log.Fatal(err) } + _, infoLog, _, errLog := logging.DefaultLoggers() + // add stdout logging to the request handler - handler := guslog.Requests(os.Stdout, nil)(inspectHandler) + handler := logging.LogRequests(infoLog)(inspectHandler) // run the server - server, err := gemini.NewServer(context.Background(), tlsconf, "tcp4", ":1965", handler) + server, err := gemini.NewServer(context.Background(), errLog, tlsconf, "tcp4", ":1965", handler) if err != nil { log.Fatal(err) } |