package log

import (
	"context"
	"log/slog"
)

type ContextKey string

const (
	ContextLogger ContextKey = "logger"
)

func WithLogger(ctx context.Context, logger *slog.Logger) context.Context {
	return context.WithValue(ctx, ContextLogger, logger)
}

func GetLogger(ctx context.Context) *slog.Logger {
	logger, ok := ctx.Value(ContextLogger).(*slog.Logger)
	if !ok {
		return slog.Default()
	}
	return logger
}
