Version: v5.22.0 Latest Latest

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

Go to latest
Published: Apr 4, 2020 License: AGPL-3.0, Apache-2.0 Imports: 12 Imported by: 0




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"


This section is empty.


func NewFileTarget

func NewFileTarget(filter logr.Filter, formatter logr.Formatter, opts FileOptions, maxQSize int) (*target.File, error)

NewFileTarget creates a target capable of outputting log records to a rotated file.


type Audit

type Audit struct {

	// OnQueueFull is called on an attempt to add an audit record to a full queue.
	// On return the calling goroutine will block until the audit record can be added.
	OnQueueFull func(qname string, maxQueueSize int)

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

func (*Audit) AddTarget

func (a *Audit) AddTarget(target logr.Target)

AddTarget adds a Logr target to the list of targets each audit record will be output to.

func (*Audit) Init

func (a *Audit) Init(maxQueueSize int)

func (*Audit) Log

func (a *Audit) Log(level 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 Level, rec Record)

LogRecord emits an audit record with complete info.

func (*Audit) MakeFilter

func (a *Audit) MakeFilter(level ...Level) *logr.CustomFilter

MakeFilter creates a filter which only allows the specified audit levels to be output.

func (*Audit) MakeJSONFormatter

func (a *Audit) MakeJSONFormatter() *format.JSON

MakeJSONFormatter creates a formatter that outputs JSON suitable for audit records.

func (*Audit) Shutdown

func (a *Audit) Shutdown()

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

type FileOptions

type FileOptions target.FileOptions

type Level

type Level logr.Level

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

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) 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.

type SyslogParams

type SyslogParams struct {
	Raddr    string
	Cert     string
	Tag      string
	Insecure bool

SyslogParams provides parameters for dialing a syslogTLS daemon.

type SyslogTLS

type SyslogTLS struct {
	// contains filtered or unexported fields

Syslog outputs log records to local or remote syslog.

func NewSyslogTLSTarget

func NewSyslogTLSTarget(filter logr.Filter, formatter logr.Formatter, params *SyslogParams, maxQueue int) (*SyslogTLS, error)

NewSyslogTLSTarget creates a target capable of outputting log records to remote or local syslog via TLS.

func (*SyslogTLS) Shutdown

func (s *SyslogTLS) Shutdown(ctx context.Context) error

Shutdown stops processing log records after making best effort to flush queue.

func (*SyslogTLS) String

func (s *SyslogTLS) String() string

String returns a string representation of this target.

func (*SyslogTLS) Write

func (s *SyslogTLS) Write(rec *logr.LogRec) error

Write converts the log record to bytes, via the Formatter, and outputs to syslog via TLS.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL