Documentation ¶
Index ¶
- Variables
- func FromContext(ctx context.Context) *slog.Logger
- func NewContext(ctx context.Context, l *slog.Logger) context.Context
- func NewStdLog(key string, debug bool, log *slog.Logger) *stdLoggerish
- func Setup() *slog.Logger
- func SetupMultiLogger() *slog.Logger
- func SetupOLTP() *slog.Logger
- type Error
Constants ¶
This section is empty.
Variables ¶
var ConfigPrefix = ""
Functions ¶
func FromContext ¶
FromContext retrieves a logger from the context. If there is none, it returns the default logger
func NewContext ¶
NewContext adds the logger to the context. Use this to for example make a request specific logger available to other functions through the context
func Setup ¶
Setup returns an slog.Logger configured for text formatting to stderr. OpenTelemetry trace_id and span_id's are logged as attributes when available. When the application is running under systemd timestamps are omitted. On first call the slog default logger is set to this logger as well.
If SetupMultiLogger has been called Setup() will return the "multi logger"
func SetupMultiLogger ¶ added in v0.3.0
SetupMultiLogger will setup and make default a logger that logs as described in Setup() as well as an OLTP logger. The "multi logger" is made the default the first time this function is called
func SetupOLTP ¶ added in v0.3.0
SetupOLTP configures and returns a logger sending logs via OpenTelemetry (configured via the tracing package).
This was made to work with Loki + Grafana that makes it hard to view the log attributes in the UI, so the log message is formatted similarly to the text logger. The attributes are duplicated as OLTP attributes in the log messages. https://github.com/grafana/loki/issues/14788