From fb9f4a7c4a5581cf3d625141f52f050f024e495a Mon Sep 17 00:00:00 2001 From: Catherine Date: Thu, 18 Sep 2025 02:00:48 +0000 Subject: [PATCH] Allow configuring log format. In a production environment the timestamp will be appended by the log service. --- src/config.go | 3 ++- src/main.go | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/config.go b/src/config.go index 688ae1f..9bd050b 100644 --- a/src/config.go +++ b/src/config.go @@ -12,7 +12,8 @@ type CacheConfig struct { } type Config struct { - Listen struct { + LogFormat string `toml:"log-format"` + Listen struct { Pages string `toml:"pages"` Caddy string `toml:"caddy"` Health string `toml:"health"` diff --git a/src/main.go b/src/main.go index ccdb8f3..6f9f7ec 100644 --- a/src/main.go +++ b/src/main.go @@ -41,6 +41,13 @@ func main() { } UpdateConfigEnv() // environment takes priority + switch config.LogFormat { + case "short": + log.SetFlags(0) + default: + log.SetFlags(log.Ldate | log.Ltime | log.LUTC) + } + switch config.Backend.Type { case "fs": if backend, err = NewFSBackend(config.Backend.FS.Root); err != nil {