Logging
Lakta provides two logging modules that work together: tint for formatting and slog for the standard library logger.
lakta.NewRuntime( config.NewModule( config.WithConfigDirs(".", "./config"), config.WithArgs(os.Args[1:]), ), tint.NewModule(), // provides slog.Handler slog.NewModule(), // provides *slog.Logger)tint module
Section titled “tint module”pkg/logging/tint wraps github.com/lmittmann/tint to produce colorized, human-readable console output.
Configuration Reference
Section titled “Configuration Reference”Config path: modules.logging.tint.<name>
time_format timeFormat specifies the format for timestamping log entries
LAKTA_MODULES_LOGGING_TINT_<NAME>_TIME_FORMAT Code-only options
Section titled “Code-only options”These options can only be set in Go code via With*() functions, not via config files or environment variables.
| Option | Type | Description |
|---|---|---|
WithWriter(...) | io.Writer | sets the output writer (code-only, cannot be configured via files) |
slog module
Section titled “slog module”pkg/logging/slog registers *slog.Logger in DI and sets it as the global default via slog.SetDefault.
Configuration Reference
Section titled “Configuration Reference”Config path: modules.logging.slog.<name>
level level represents the default log level to be used in the configuration
LAKTA_MODULES_LOGGING_SLOG_<NAME>_LEVEL levels levels defines a map of per-package log level overrides
LAKTA_MODULES_LOGGING_SLOG_<NAME>_LEVELS global_default globalDefault indicates whether the logger should be set as the default globally
LAKTA_MODULES_LOGGING_SLOG_<NAME>_GLOBAL_DEFAULT Context-aware logging
Section titled “Context-aware logging”Use github.com/Vilsol/slox to log with the context-carried logger:
slox.Info(ctx, "request received", slog.String("path", r.URL.Path))slox.Error(ctx, "query failed", slog.Any("err", err))This ensures log records carry the correct logger (including any fields injected by middleware).