package services

import (
	"context"

	"quyun/v2/pkg/consts"

	"github.com/sirupsen/logrus"
	"github.com/spf13/cast"
)

// @provider
type audit struct{}

func (s *audit) Log(ctx context.Context, action, targetID, detail string) {
	operatorID := cast.ToInt64(ctx.Value(consts.CtxKeyUser))
	logrus.WithFields(logrus.Fields{
		"audit":    true,
		"operator": operatorID,
		"action":   action,
		"target":   targetID,
		"detail":   detail,
	}).Info("Audit Log")
}
