utils

package
v0.0.0-...-d5842fd Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxCWD

func CtxCWD(ctx context.Context) string

func CtxLogger

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

func CtxRequestID

func CtxRequestID(ctx context.Context) (context.Context, types.RequestID)

WithRequestID returns context with request ID. If request ID is already set, it returns same context. If not, it generates new request ID and set it and logger to context.

func CtxWithCWD

func CtxWithCWD(ctx context.Context, dir string) context.Context

func CtxWithLogger

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

func ErrLog

func ErrLog(err error) slog.Attr

func HandleError

func HandleError(ctx context.Context, msg string, err error)

func LoadEnv

func LoadEnv(envs ...EnvLoader) error

func Logger

func Logger() *slog.Logger

func ReconfigureLogger

func ReconfigureLogger(handler slog.Handler)

func SafeClose

func SafeClose(c Closer)

func SafeWrite

func SafeWrite(w io.Writer, b []byte)

Types

type Closer

type Closer interface {
	Close() error
}

type EnvLoader

type EnvLoader func() error

func Env

func Env(key string, dst *string) EnvLoader

Jump to

Keyboard shortcuts

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