better logging

This commit is contained in:
Simon Martens
2024-11-16 17:30:14 +01:00
parent 527fbfa000
commit 84fa6f7fa4
17 changed files with 221 additions and 106 deletions

View File

@@ -7,6 +7,7 @@ import (
"strings"
"github.com/Theodor-Springmann-Stiftung/kgpz_web/helpers"
"github.com/Theodor-Springmann-Stiftung/kgpz_web/helpers/logging"
"github.com/kelseyhightower/envconfig"
)
@@ -68,15 +69,14 @@ func (c *ConfigProvider) Validate() error {
func readSettingsFile(cfg *Config, path string) *Config {
f, err := os.Open(path)
if err != nil {
fmt.Println("Error: ", err)
fmt.Println("Coudln't open ", path)
logging.Error(err, "Error opening config file "+path)
return cfg
}
defer f.Close()
dec := json.NewDecoder(f)
err = dec.Decode(cfg)
helpers.MaybePanic(err, "Error decoding config.json")
helpers.Assert(err, "Error decoding config file")
return cfg
}