audit

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventShutdown = "shutdown"
	EventStartUp  = "startup"
)
View Source
const (
	ModuleSystem = "system"
)

Variables

View Source
var (
	Logger *logger
)

Functions

func DeRegisterModules

func DeRegisterModules(ms ...string)

func Init

func Init(ctx context.Context)

func Plugin

func Plugin(prefix string, middleware ...ghttp.HandlerFunc) ghttp.Plugin

func RegisterModules

func RegisterModules(ms ...string)

func SetAdaptor

func SetAdaptor(adaptor RecordAdaptor)

func SupportedModules

func SupportedModules() []string

func Sys

func Sys(ctx context.Context, event string, content ...interface{})

Types

type ILogger

type ILogger interface {
	io.Closer
	Ctx(ctx context.Context) *logger
	Module(module string) *logger
	Log(event string, content ...interface{})
}

type MysqlAdaptor

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

func NewMysqlAdaptor

func NewMysqlAdaptor(db gdb.DB, logger *glog.Logger, tableName ...string) (m *MysqlAdaptor, err error)

func (*MysqlAdaptor) Load

func (m *MysqlAdaptor) Load(ctx context.Context, params *RecordQueryParams) (res *RecordQueryResult, err error)

func (*MysqlAdaptor) Store

func (m *MysqlAdaptor) Store(ctx context.Context, record *Record) (err error)

type Record

type Record struct {
	Module    string      `json:"module"`     // module
	Event     string      `json:"event"`      // event name
	From      string      `json:"from"`       // identity
	Content   interface{} `json:"content"`    // content
	CreatedAt time.Time   `json:"created_at"` // created_at
}

type RecordAdaptor

type RecordAdaptor interface {
	Store(ctx context.Context, record *Record) (err error)
	Load(ctx context.Context, params *RecordQueryParams) (res *RecordQueryResult, err error)
}

type RecordContent

type RecordContent struct {
	Meta  *meta.Meta  `json:"meta"`
	Value interface{} `json:"value"`
	Error string      `json:"error"`
}

func Content

func Content(ctx context.Context, v ...interface{}) *RecordContent

type RecordQueryParams

type RecordQueryParams struct {
	Module   string     `json:"module"`
	Event    string     `json:"event"`
	From     string     `json:"from"`
	Start    *time.Time `json:"start"`
	End      *time.Time `json:"end"`
	PageSize int        `json:"page_size"`
	PageNum  int        `json:"page_num"`
}

type RecordQueryResult

type RecordQueryResult struct {
	Records []*Record `json:"records"`
	Total   int       `json:"total"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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