summaryrefslogtreecommitdiff
path: root/gemini
diff options
context:
space:
mode:
authortjpcc <tjp@ctrl-c.club>2023-01-23 22:15:16 -0700
committertjpcc <tjp@ctrl-c.club>2023-01-23 22:15:16 -0700
commit0480e066a3f1ae97dbab8fcb6303589eb0fa724c (patch)
tree1aa347eb3691a29987475fcf6049343aa227a365 /gemini
parentdf57a12539030297b3254bc81f5696691cbc9c6f (diff)
logging library up to top level
Diffstat (limited to 'gemini')
-rw-r--r--gemini/roundtrip_test.go2
-rw-r--r--gemini/serve.go7
2 files changed, 8 insertions, 1 deletions
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
}