all repos — website @ 604e9342d92742022943feba62ce812d6ad1dc8f

My website

use unbuffered logs in development
Alan Pearce alan@alanpearce.eu
Fri, 19 Apr 2024 07:29:23 +0200
commit

604e9342d92742022943feba62ce812d6ad1dc8f

parent

90691c33d451ce355e803680c4406cc5ab8e8bcc

1 files changed, 8 insertions(+), 1 deletions(-)

jump to
M server.goserver.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"