Documentation
¶
Overview ¶
Package observability sets up structured logging with log/slog, so every binary (a local server, a Lambda, a daemon, a tool) logs the same way: JSON on stderr, tagged with its environment, at a level read from an environment variable. It sets up logging only.
Index ¶
Constants ¶
const DefaultLevelEnvVar = "LOG_LEVEL"
DefaultLevelEnvVar is the environment variable consulted by Init to choose the log level. Consuming services that prefer a project-specific variable (for example "MYAPP_LOG_LEVEL") can call InitWithLevelVar instead.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
Init constructs a JSON slog.Logger, installs it as the process default, and returns it for callers that want a direct handle. The level is read from the LOG_LEVEL environment variable (debug|info|warn|error); unrecognized or unset values fall back to info.
Call Init once at the start of main(). All log/slog package-level functions then route through the configured handler.
func InitWithLevelVar ¶
InitWithLevelVar behaves like Init but reads the level from a caller-chosen environment variable, allowing a service to honor its own prefixed variable (for example "MYAPP_LOG_LEVEL") without leaking project naming into this module.
Types ¶
This section is empty.