Documentation ¶
Index ¶
- Constants
- func NewFileTarget(filter logr.Filter, formatter logr.Formatter, opts FileOptions, maxQSize int) (*target.File, error)
- type Audit
- func (a *Audit) AddTarget(target logr.Target)
- func (a *Audit) Init(maxQueueSize int)
- func (a *Audit) Log(level mlog.LogLevel, path string, evt string, status string, userID string, ...)
- func (a *Audit) LogRecord(level mlog.LogLevel, rec Record)
- func (a *Audit) MakeFilter(level ...mlog.LogLevel) *logr.CustomFilter
- func (a *Audit) MakeJSONFormatter() *format.JSON
- func (a *Audit) Shutdown()
- type FileOptions
- type FuncMetaTypeConv
- type Meta
- type Record
Constants ¶
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 ¶
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) AddTarget ¶
AddTarget adds a Logr target to the list of targets each audit record will be output to.
func (*Audit) Log ¶
func (a *Audit) Log(level mlog.LogLevel, path string, evt string, status string, userID string, sessionID string, meta Meta)
Log emits an audit record based on minimum required info.
func (*Audit) MakeFilter ¶
func (a *Audit) MakeFilter(level ...mlog.LogLevel) *logr.CustomFilter
MakeFilter creates a filter which only allows the specified audit levels to be output.
func (*Audit) MakeJSONFormatter ¶
MakeJSONFormatter creates a formatter that outputs JSON suitable for audit records.
type FileOptions ¶
type FileOptions target.FileOptions
type FuncMetaTypeConv ¶ added in v5.24.0
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) AddMetaTypeConverter ¶ added in v5.24.0
func (rec *Record) AddMetaTypeConverter(f FuncMetaTypeConv)
AddMetaTypeConverter adds a function capable of converting meta field types into something more suitable for serialization.