feat: add configurable loglevel
This commit is contained in:
+9
-6
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user