diff options
author | Alan Pearce | 2024-04-19 07:29:23 +0200 |
---|---|---|
committer | Alan Pearce | 2024-04-19 07:29:23 +0200 |
commit | 604e9342d92742022943feba62ce812d6ad1dc8f (patch) | |
tree | 56e5551014219415504ea8ad724c419b4e48998c | |
parent | 90691c33d451ce355e803680c4406cc5ab8e8bcc (diff) | |
download | website-604e9342d92742022943feba62ce812d6ad1dc8f.tar.lz website-604e9342d92742022943feba62ce812d6ad1dc8f.tar.zst website-604e9342d92742022943feba62ce812d6ad1dc8f.zip |
use unbuffered logs in development
-rw-r--r-- | server.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/server.go b/server.go index 0681a34..5ed4561 100644 --- a/server.go +++ b/server.go @@ -3,6 +3,7 @@ package main import ( "embed" "fmt" + "io" "log" "net/http" "os" @@ -123,8 +124,14 @@ func main() { 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" |