log

package
v0.0.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithLogger

func ContextWithLogger(ctx context.Context, logger *slog.Logger) context.Context

ContextWithLogger stuffs the given logger (or a new logger if nil) into a context and returns that.

func LogLevelFromEnv

func LogLevelFromEnv() slog.Level

LogLevelFromEnv parses the `PULUMI_MID_LOG_LEVEL` environment variable to get the logging level. It defaults to "INFO" if the environment variable is not set or if it was set to an invalid value.

func LoggerFromContext

func LoggerFromContext(ctx context.Context) *slog.Logger

LoggerFromContext retrieves the logger from a context previously set with ContextWithLogger or returns a new logger if one was not found.

func NewLogger

func NewLogger() *slog.Logger

NewLogger builds a new slog logger which writes to stderr. We need to write to stderr and _not_ stdout because stdout is used for IPC stuff.

func SlogJSON

func SlogJSON(key string, value any) slog.Attr

SlogJSON JSON marshals any value into a slog.Attr.

Types

type ContextKey

type ContextKey string
const LoggerContextKey ContextKey = "sapslaj.mid.logger"

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL