Commit 931cd595117d96d8e49b045c475260c351c2d86d

Parents: 94034c782c42b58008d2eede9cd0411a901fe711

From: Moritz Poldrack <git@moritz.sh>
Date: Thu Nov 9 14:16:49 2023 +0700

log: log errors

		

Stats

internal/handler/404.go +5/-0

Changeset

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
diff --git a/internal/handler/404.go b/internal/handler/404.go
index dd387f7bc07a44578fac69876145d2833bd240f5..c564165b5a41e43c746559913ddc5b53b93d8de2 100644
--- a/internal/handler/404.go
+++ b/internal/handler/404.go
@@ -4,14 +4,19 @@ import (
 	"errors"
 	"fmt"
 
+	"git.sr.ht/~mpldr/gogit/internal/conman"
 	"github.com/valyala/fasthttp"
 )
 
 func errorHandler(ctx *fasthttp.RequestCtx, err error) {
+	log := conman.GetLogger(ctx)
 	status := fasthttp.StatusInternalServerError
 	switch {
 	case errors.Is(err, ErrNotFound):
 		status = fasthttp.StatusNotFound
+		log.Warn(err.Error(), "path", ctx.Path())
+	default:
+		log.Error("internal server error", "error", err.Error())
 	}
 	ctx.SetStatusCode(status)