Documentation
¶
Overview ¶
Package logging configures process-wide structured logging for GoatFlow.
It honours three environment variables (documented in .env.example):
LOG_FORMAT=json|text — output format (default: text)
LOG_LEVEL=debug|info|warn|error — minimum level for slog (default: info)
LOG_OUTPUT=stdout|<path> — where logs are written (default: stdout).
LOG_FILE_PATH=<path> — legacy alias: used as the destination when
LOG_OUTPUT is unset/empty, so existing
deployments keep their log file.
Two log sinks are configured so the whole codebase behaves consistently:
- slog — a level-aware JSON or Text handler becomes the default logger (slog.SetDefault), so every slog.* call in the codebase is structured.
- stdlib log — legacy log.Printf call sites are routed through a format-aware writer, so they respect the same LOG_FORMAT and LOG_OUTPUT. In JSON mode each line goes through the slog JSON handler, so both kinds of record share one layout ("level":"INFO" etc.). stdlib log carries no level metadata, so its lines are always emitted at INFO; only slog lines are filtered by LOG_LEVEL.
Index ¶
Constants ¶
View Source
const ( FormatText = "text" FormatJSON = "json" )
Variables ¶
This section is empty.
Functions ¶
func Configure ¶
Configure sets up slog and the stdlib log package from the environment. It is safe to call more than once (last call wins) and returns the configured slog.Logger for callers that prefer it.
func NormalizeFormat ¶
func ParseLevel ¶
func RunCleanupHooks ¶
func RunCleanupHooks()
RunCleanupHooks closes any managed log files. Called from main on exit.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.