feat: add configurable loglevel

This commit is contained in:
2026-04-22 22:29:58 +02:00
parent d6df67b643
commit f796ea229f
7 changed files with 38 additions and 17 deletions
+9 -6
View File
@@ -9,23 +9,26 @@ import (
)
func main() {
// grab the environment variables from the runtime environment
env := utility.GrabEnvironment()
// configure the logger so we have nice json
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
level := utility.ParseSlogLevel(env.LogLevel) // defaults to Info
logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
Level: &level,
}))
slog.SetDefault(logger)
// grab the environment variables from the runtime environment
slog.Info("grabbing environment variables")
env := utility.GrabEnvironment()
// print our running environment variable set
slog.Debug("environment", "env", env)
// TO DO, allow cmd args parsing
// checking directories to ensure its expected environment is ready
slog.Info("auditing operating environment")
slog.Debug("checking if directories are present")
if err := utility.EnsureOperation(env.DataDirectory); err != nil {
slog.Error("failed to ensure the operating environment", "error", err)
os.Exit(1)
}
slog.Info("finished audit of environment")
// initiating the database connection for which we safe things
slog.Info("kicking off database connection")