From 973fa31b6743a3ea84c86ab7671349cc70a69142 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sat, 29 Jun 2024 21:27:35 +0200 Subject: enable filtered debug logging via DEBUG="component.*" --- cmd/build/main.go | 10 ++++++++-- cmd/cspgenerator/cspgenerator.go | 3 +-- cmd/server/main.go | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'cmd') diff --git a/cmd/build/main.go b/cmd/build/main.go index 14175e9..39cbc1b 100644 --- a/cmd/build/main.go +++ b/cmd/build/main.go @@ -5,6 +5,7 @@ import ( "os" "go.alanpearce.eu/website/internal/builder" + "go.alanpearce.eu/website/internal/config" "go.alanpearce.eu/website/internal/log" "github.com/ardanlabs/conf/v3" @@ -20,7 +21,7 @@ func main() { } panic("error parsing configuration: " + err.Error()) } - log.Configure(!ioConfig.Development) + log := log.Configure(!ioConfig.Development) log.Debug("starting build process") if ioConfig.Source != "." { @@ -29,7 +30,12 @@ func main() { log.Panic("could not change to source directory") } } - _, err := builder.BuildSite(ioConfig, nil) + cfg, err := config.GetConfig(ioConfig.Source, log) + if err != nil { + log.Error("could not read config", "error", err) + } + + _, err = builder.BuildSite(ioConfig, cfg, log) if err != nil { log.Error("could not build site", "error", err) os.Exit(1) diff --git a/cmd/cspgenerator/cspgenerator.go b/cmd/cspgenerator/cspgenerator.go index 1b9b9ba..0252d32 100644 --- a/cmd/cspgenerator/cspgenerator.go +++ b/cmd/cspgenerator/cspgenerator.go @@ -2,12 +2,11 @@ package main import ( "go.alanpearce.eu/website/internal/config" - "go.alanpearce.eu/website/internal/log" ) func main() { err := config.GenerateCSP() if err != nil { - log.Fatal("error generating csp", "error", err) + panic(err) } } diff --git a/cmd/server/main.go b/cmd/server/main.go index 576cfb3..b74a0cc 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -23,7 +23,7 @@ func main() { } panic("parsing runtime configuration" + err.Error()) } - log.Configure(!runtimeConfig.Development) + log := log.Configure(!runtimeConfig.Development) if runtimeConfig.Development { tmpdir, err := os.MkdirTemp("", "website") @@ -34,7 +34,7 @@ func main() { runtimeConfig.Root = tmpdir } - sv, err := server.New(&runtimeConfig) + sv, err := server.New(&runtimeConfig, log) if err != nil { log.Error("could not create server", "error", err) -- cgit 1.4.1