Initial commit.
Linting and tests / Linting (push) Failing after 30s
Linting and tests / Tests (push) Successful in 25s

This commit is contained in:
2026-06-10 10:23:00 +05:00
commit 3d43b8a84e
34 changed files with 1325 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
package application
import (
"log/slog"
"os"
"strings"
)
const (
defaultLogLevel slog.Level = slog.LevelInfo
logLevelEnvVar = "VN_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: logLevel,
}))
a.appLogger = a.baseLogger.With("module", "application")
}
// NewLogger creates new sub-instance of base logger and adds some additional data to it for persistent output.
func (a *Application) NewLogger(withs ...any) *slog.Logger {
return a.baseLogger.With(withs...)
}