audit

package
v0.0.0-...-be78fc5 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefault

func SetDefault(audit *Audit)

func WithAudit

func WithAudit(ctx context.Context, audit *Audit) context.Context

Types

type Audit

type Audit struct {
	// contains filtered or unexported fields
}

func Default

func Default() *Audit

func NewAudit

func NewAudit(opts ...Option) *Audit

NewAudit 创建审计 你可以实现 Storage 接口来自定义审计存储 默认的话可以使用日志组件来存储审计日志

func (*Audit) Middleware

func (a *Audit) Middleware(module string, getFields func(ctx *gin.Context) []zap.Field) gin.HandlerFunc

Middleware 中间件 可以添加自定义的字段

func (*Audit) Module

func (a *Audit) Module(module string) *Audit

Module 设置模块

func (*Audit) Record

func (a *Audit) Record(ctx context.Context, eventName string, fields ...zap.Field) error

Record 记录审计日志

func (*Audit) With

func (a *Audit) With(fields ...zap.Field) *Audit

With 添加字段

type CtxAudit

type CtxAudit struct {
	context.Context
	*Audit
}

func Ctx

func Ctx(ctx context.Context) *CtxAudit

func NewCtxAudit

func NewCtxAudit(ctx context.Context, audit *Audit) *CtxAudit

func (*CtxAudit) Record

func (c *CtxAudit) Record(eventName string, fields ...zap.Field) error

type Option

type Option func(*Options)

func WithStorage

func WithStorage(storage Storage) Option

type Options

type Options struct {
	// contains filtered or unexported fields
}

type Storage

type Storage interface {
	Record(ctx context.Context, module, eventName string, fields ...zap.Field) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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