From 0480e066a3f1ae97dbab8fcb6303589eb0fa724c Mon Sep 17 00:00:00 2001 From: tjpcc Date: Mon, 23 Jan 2023 22:15:16 -0700 Subject: logging library up to top level --- gemini/roundtrip_test.go | 2 +- gemini/serve.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'gemini') diff --git a/gemini/roundtrip_test.go b/gemini/roundtrip_test.go index 326ffbc..4bac239 100644 --- a/gemini/roundtrip_test.go +++ b/gemini/roundtrip_test.go @@ -23,7 +23,7 @@ func TestRoundTrip(t *testing.T) { return gemini.Success("text/gemini", bytes.NewBufferString("you've found my page")) } - server, err := gemini.NewServer(context.Background(), tlsConf, "tcp", "127.0.0.1:0", handler) + server, err := gemini.NewServer(context.Background(), nil, tlsConf, "tcp", "127.0.0.1:0", handler) if err != nil { t.Fatalf("NewServer(): %s", err.Error()) } diff --git a/gemini/serve.go b/gemini/serve.go index c148558..cd51370 100644 --- a/gemini/serve.go +++ b/gemini/serve.go @@ -8,10 +8,12 @@ import ( "sync" "tildegit.org/tjp/gus" + "tildegit.org/tjp/gus/logging" ) type server struct { ctx context.Context + errorLog logging.Logger network string address string cancel context.CancelFunc @@ -23,6 +25,7 @@ type server struct { // NewServer builds a gemini server. func NewServer( ctx context.Context, + errorLog logging.Logger, tlsConfig *tls.Config, network string, address string, @@ -37,6 +40,7 @@ func NewServer( s := &server{ ctx: ctx, + errorLog: errorLog, network: addr.Network(), address: addr.String(), wg: &sync.WaitGroup{}, @@ -69,7 +73,10 @@ func (s *server) Serve() error { if err != nil { if s.Closed() { err = nil + } else { + s.errorLog.Log("msg", "accept_error", "error", err) } + return err } -- cgit v1.2.3