package biz

import (
	"context"
	"log/slog"
)

// PaymentLogger isolates payment audit logging from the payment workflow and
// lets an application replace slog with its own structured logger.
type PaymentLogger interface {
	Info(context.Context, string, ...any)
	Error(context.Context, string, ...any)
}

type slogPaymentLogger struct {
	logger *slog.Logger
}

func NewPaymentLogger(logger *slog.Logger) PaymentLogger {
	if logger == nil {
		logger = slog.Default()
	}
	return &slogPaymentLogger{logger: logger.With("mod", "payment")}
}

func (l *slogPaymentLogger) Info(ctx context.Context, message string, args ...any) {
	l.logger.InfoContext(ctx, message, args...)
}

func (l *slogPaymentLogger) Error(ctx context.Context, message string, args ...any) {
	l.logger.ErrorContext(ctx, message, args...)
}
