auditlogdriver

package
v0.0.0-...-e7c744b Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(db *gorm.DB, logger common.Logger) error

Migrate executes the table migrations for the audit model.

func NewDatabaseDriver

func NewDatabaseDriver(db *gorm.DB) auditlog.Driver

NewDatabaseDriver returns an audit log driver that records entries in the database.

func NewLogDriver

func NewLogDriver(config LogDriverConfig, logger Logger) auditlog.Driver

NewLogDriver returns a standard output audit log driver.

Types

type EntryModel

type EntryModel struct {
	ID            uint      `gorm:"primary_key"`
	Time          time.Time `gorm:"index"`
	CorrelationID string    `gorm:"size:36"`
	ClientIP      string    `gorm:"size:45"`
	UserAgent     string
	Path          string `gorm:"size:8000"`
	Method        string `gorm:"size:7"`
	UserID        uint
	StatusCode    int
	Body          *string `gorm:"type:json"`
	Headers       string  `gorm:"type:json"`
	ResponseTime  int
	ResponseSize  int
	Errors        *string `gorm:"type:json"`
}

EntryModel holds all information related to a user interaction.

func (EntryModel) TableName

func (EntryModel) TableName() string

TableName specifies a database table name for the model.

type LogDriverConfig

type LogDriverConfig struct {
	Verbosity int
	Fields    []string
}

LogDriverConfig configures a standard output audit log driver.

type Logger

type Logger interface {
	// Info logs an info event.
	Info(msg string, fields ...map[string]interface{})
}

Logger is the fundamental interface for all log operations.

Jump to

Keyboard shortcuts

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