log

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: GPL-2.0, GPL-2.0-or-later Imports: 13 Imported by: 2

Documentation

Overview

Package log prints messages to a given writer, /dev/log, /dev/kmsg, or a byte buffer until one of these are available.

Index

Constants

View Source
const DevKmsg = "/dev/kmsg"
View Source
const DevLog = "/dev/log"
View Source
const FacilityMask = ^PriorityMask
View Source
const PriorityMask = syslog.Priority(7)

Variables

View Source
var FacilityByName = map[string]syslog.Priority{
	"kern":   syslog.LOG_KERN,
	"user":   syslog.LOG_USER,
	"mail":   syslog.LOG_MAIL,
	"daemon": syslog.LOG_DAEMON,
	"auth":   syslog.LOG_AUTH,
	"syslog": syslog.LOG_SYSLOG,
	"lpr":    syslog.LOG_LPR,
	"news":   syslog.LOG_NEWS,
	"uucp":   syslog.LOG_UUCP,
	"cron":   syslog.LOG_CRON,
	"priv":   syslog.LOG_AUTHPRIV,
	"ftp":    syslog.LOG_FTP,
	"local0": syslog.LOG_LOCAL0,
	"local1": syslog.LOG_LOCAL1,
	"local2": syslog.LOG_LOCAL2,
	"local3": syslog.LOG_LOCAL3,
	"local4": syslog.LOG_LOCAL4,
	"local5": syslog.LOG_LOCAL5,
	"local6": syslog.LOG_LOCAL6,
	"local7": syslog.LOG_LOCAL7,
}
View Source
var LogFacilityByValue = map[syslog.Priority]string{
	syslog.LOG_KERN:     "kern",
	syslog.LOG_USER:     "user",
	syslog.LOG_MAIL:     "mail",
	syslog.LOG_DAEMON:   "daemon",
	syslog.LOG_AUTH:     "auth",
	syslog.LOG_SYSLOG:   "syslog",
	syslog.LOG_LPR:      "lpr",
	syslog.LOG_NEWS:     "news",
	syslog.LOG_UUCP:     "uucp",
	syslog.LOG_CRON:     "cron",
	syslog.LOG_AUTHPRIV: "priv",
	syslog.LOG_FTP:      "ftp",
	syslog.LOG_LOCAL0:   "local0",
	syslog.LOG_LOCAL1:   "local1",
	syslog.LOG_LOCAL2:   "local2",
	syslog.LOG_LOCAL3:   "local3",
	syslog.LOG_LOCAL4:   "local4",
	syslog.LOG_LOCAL5:   "local5",
	syslog.LOG_LOCAL6:   "local6",
	syslog.LOG_LOCAL7:   "local7",
}
View Source
var LogPriorityByValue = map[syslog.Priority]string{
	syslog.LOG_EMERG:   "emerg",
	syslog.LOG_ALERT:   "alert",
	syslog.LOG_CRIT:    "crit",
	syslog.LOG_ERR:     "err",
	syslog.LOG_WARNING: "warn",
	syslog.LOG_NOTICE:  "note",
	syslog.LOG_INFO:    "info",
	syslog.LOG_DEBUG:   "debug",
}
View Source
var PriorityByName = map[string]syslog.Priority{
	"emerg": syslog.LOG_EMERG,
	"alert": syslog.LOG_ALERT,
	"crit":  syslog.LOG_CRIT,
	"err":   syslog.LOG_ERR,
	"warn":  syslog.LOG_WARNING,
	"note":  syslog.LOG_NOTICE,
	"info":  syslog.LOG_INFO,
	"debug": syslog.LOG_DEBUG,
}

Functions

func LinesFrom

func LinesFrom(rc io.ReadCloser, id, priority string)

log lines from the given reader until EOF or error.

func Print

func Print(args ...interface{})

The default level is: Debug, User. Upto the first two arguments may change this by name; e.g.

Print("daemon", ...)
Print("daemon", "err", ...)
Print("err", ...)

func Printf

func Printf(args ...interface{})

The default level is: Debug, User. Upto the first two arguments may preceed the log format string to change the priority and facility like this:

Printf("daemon", format, ...)
Printf("daemon", "err", format, ...)
Printf("err", format, ...)

func Tee

func Tee(w io.Writer)

Tee logged lines to Writer

Types

type Delta

type Delta uint64

func (Delta) Sec

func (delta Delta) Sec() uint64

func (Delta) String

func (delta Delta) String() string

func (Delta) Usec

func (delta Delta) Usec() uint64

type Kmsg

type Kmsg struct {
	Pri   syslog.Priority
	Seq   Seq
	Stamp Stamp
	Msg   string
}

func (*Kmsg) IsKern

func (p *Kmsg) IsKern() bool

func (*Kmsg) Parse

func (p *Kmsg) Parse(b []byte)

type Limited

type Limited struct {
	sync.Mutex
	N uint32
	// contains filtered or unexported fields
}

Limited provides a logger with Print and Printf restricted to the given iterations.

func NewLimited

func NewLimited(n uint32) *Limited

NewLimited returns a logger with the given iteration restriction.

func (*Limited) Print

func (l *Limited) Print(args ...interface{})

func (*Limited) Printf

func (l *Limited) Printf(args ...interface{})

type RateLimited

type RateLimited struct {
	*Limited
	// contains filtered or unexported fields
}

RateLimited provides a logger with Print and Printf restricted to the given iterations per unit time. This must be created with NewRateLimited and destroyed with (*RateLimited).Close().

func NewRateLimited

func NewRateLimited(n uint32, d time.Duration) *RateLimited

NewRateLimited returns a logger restricted to the given iterations per unit time that should be destroyed with `defer (*RateLimited).Close()`

func (*RateLimited) Close

func (p *RateLimited) Close() error

type Seq

type Seq uint64

type Stamp

type Stamp uint64

func (Stamp) Delta

func (stamp Stamp) Delta(last Stamp) Delta

func (Stamp) Sec

func (stamp Stamp) Sec() uint64

func (Stamp) String

func (stamp Stamp) String() string

func (Stamp) Time

func (stamp Stamp) Time(now time.Time, uptime int64) time.Time

func (Stamp) Usec

func (stamp Stamp) Usec() uint64

Jump to

Keyboard shortcuts

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