From 93353c75510360d3cf5bfefba5dd7abcabeee519 Mon Sep 17 00:00:00 2001 From: Odyssey Date: Sat, 7 Jan 2023 17:48:15 +0100 Subject: [PATCH] add logging to online Signed-off-by: Odyssey --- main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.go b/main.go index 12b8d1b..b56b8f3 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "github.com/ProjectSegfault/publapi/pages" "github.com/gofiber/fiber/v2" + "go.uber.org/zap" ) // publapi is a simple API for Project Segfault's public shared server (pubnix). @@ -20,9 +21,15 @@ func main() { }) app.Get("/online", func(c *fiber.Ctx) error { + + // set up logger + logger, _ := zap.NewProduction() + defer logger.Sync() + // Get the number of users online out, err := exec.Command("users | wc -l").Output() if err != nil { + logger.Error("failed to get number of users online", zap.Error(err)) return c.SendStatus(fiber.StatusInternalServerError) }