Re-work loading of configuration, introduce a loader for start up & and custom logging wrapper.
This commit is contained in:
24
logging/config.go
Normal file
24
logging/config.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package logging
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
|
||||
"synlotto-website/models"
|
||||
)
|
||||
|
||||
func LogConfig(config *models.Config) {
|
||||
safeConfig := *config
|
||||
safeConfig.CSRF.CSRFKey = "[REDACTED]"
|
||||
safeConfig.Session.SessionAuthKey = "[REDACTED]"
|
||||
safeConfig.Session.SessionEncryptionKey = "[REDACTED]"
|
||||
|
||||
cfg, err := json.MarshalIndent(safeConfig, "", " ")
|
||||
if err != nil {
|
||||
log.Println("Failed to log config:", err)
|
||||
return
|
||||
}
|
||||
|
||||
log.Println("App starting with config:")
|
||||
log.Println(string(cfg))
|
||||
}
|
||||
13
logging/messages.go
Normal file
13
logging/messages.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package logging
|
||||
|
||||
import (
|
||||
"log"
|
||||
)
|
||||
|
||||
func Info(msg string, args ...any) {
|
||||
log.Printf("[INFO] "+msg, args...)
|
||||
}
|
||||
|
||||
func Error(msg string, args ...any) {
|
||||
log.Printf("[ERROR] "+msg, args...)
|
||||
}
|
||||
Reference in New Issue
Block a user