use unbuffered logs in development
Alan Pearce alan@alanpearce.eu
Fri, 19 Apr 2024 07:29:23 +0200
1 files changed, 8 insertions(+), 1 deletions(-)
jump to
M server.go → server.go
@@ -3,6 +3,7 @@ import ( "embed" "fmt" + "io" "log" "net/http" "os" @@ -123,8 +124,14 @@ }) toplevel.Get("/health", func(c *fiber.Ctx) error { return c.SendStatus(fiber.StatusOK) }) + var logWriter io.Writer + if config.Production { + logWriter = law.NewWriteAsyncer(os.Stdout, nil) + } else { + logWriter = os.Stdout + } toplevel.Use(skip.New(logger.New(logger.Config{ - Output: law.NewWriteAsyncer(os.Stdout, nil), + Output: logWriter, Format: "${protocol} ${method} ${status} ${host} ${url} ${respHeader:Location}\n", }), func(c *fiber.Ctx) bool { return c.Hostname() == "fly-internal"