Basic server app with WS connection.
Some checks failed
Linting and tests / Linting (push) Failing after 37s

This commit is contained in:
2025-09-15 09:33:25 +05:00
parent 466b58b41d
commit 2c13e3f380
25 changed files with 928 additions and 27 deletions

View File

@@ -3,12 +3,37 @@ package application
import (
"log/slog"
"os"
"strings"
)
const (
defaultLogLevel slog.Level = slog.LevelInfo
logLevelEnvVar = "BUNKERD_LOG_LEVEL"
)
func (a *Application) initializeLogger() {
logLevel := defaultLogLevel
logLevelAsString, found := os.LookupEnv(logLevelEnvVar)
if found {
switch strings.ToLower(logLevelAsString) {
case "debug":
logLevel = slog.LevelDebug
case "info":
logLevel = slog.LevelInfo
case "warn":
logLevel = slog.LevelWarn
case "error":
logLevel = slog.LevelError
}
}
slog.Warn("Setting log level.", "level", logLevel.String())
a.baseLogger = slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
AddSource: true,
Level: slog.LevelDebug,
Level: logLevel,
}))
a.appLogger = a.baseLogger.With("module", "application")