Basic server app with WS connection.
Some checks failed
Linting and tests / Linting (push) Failing after 37s
Some checks failed
Linting and tests / Linting (push) Failing after 37s
This commit is contained in:
@@ -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")
|
||||
|
Reference in New Issue
Block a user