audit

package
v6.7.2 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: AGPL-3.0, Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefMaxQueueSize = 1000

	KeyAPIPath   = "api_path"
	KeyEvent     = "event"
	KeyStatus    = "status"
	KeyUserID    = "user_id"
	KeySessionID = "session_id"
	KeyClient    = "client"
	KeyIPAddress = "ip_address"
	KeyClusterID = "cluster_id"

	Success = "success"
	Attempt = "attempt"
	Fail    = "fail"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Audit

type Audit struct {

	// OnQueueFull is called on an attempt to add an audit record to a full queue.
	// Return true to drop record, or false to block until there is room in queue.
	OnQueueFull func(qname string, maxQueueSize int) bool

	// OnError is called when an error occurs while writing an audit record.
	OnError func(err error)
	// contains filtered or unexported fields
}

func (*Audit) Configure

func (a *Audit) Configure(cfg mlog.LoggerConfiguration) error

Configure sets zero or more target to output audit logs to.

func (*Audit) Flush

func (a *Audit) Flush() error

Flush attempts to write all queued audit records to all targets.

func (*Audit) Init

func (a *Audit) Init(maxQueueSize int)

func (*Audit) Log

func (a *Audit) Log(level mlog.Level, path string, evt string, status string, userID string, sessionID string, meta Meta)

Log emits an audit record based on minimum required info.

func (*Audit) LogRecord

func (a *Audit) LogRecord(level mlog.Level, rec Record)

LogRecord emits an audit record with complete info.

func (*Audit) Shutdown

func (a *Audit) Shutdown() error

Shutdown cleanly stops the audit engine after making best efforts to flush all targets.

type FuncMetaTypeConv

type FuncMetaTypeConv func(val interface{}) (newVal interface{}, converted bool)

FuncMetaTypeConv defines a function that can convert meta data types into something that serializes well for audit records.

type Meta

type Meta map[string]interface{}

Meta represents metadata that can be added to a audit record as name/value pairs.

type Record

type Record struct {
	APIPath   string
	Event     string
	Status    string
	UserID    string
	SessionID string
	Client    string
	IPAddress string
	Meta      Meta
	// contains filtered or unexported fields
}

Record provides a consistent set of fields used for all audit logging.

func (*Record) AddMeta

func (rec *Record) AddMeta(name string, val interface{})

AddMeta adds a single name/value pair to this audit record's metadata.

func (*Record) AddMetaTypeConverter

func (rec *Record) AddMetaTypeConverter(f FuncMetaTypeConv)

AddMetaTypeConverter adds a function capable of converting meta field types into something more suitable for serialization.

func (*Record) Fail

func (rec *Record) Fail()

Success marks the audit record status as failed.

func (*Record) Success

func (rec *Record) Success()

Success marks the audit record status as successful.

Jump to

Keyboard shortcuts

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