log

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2021 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

View Source
const LogTimeFormat = "2006-01-02T15:04:05.000-0700"

LogTimeFormat is a date-time format to be displayed in the log output

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	// contains filtered or unexported fields
}

Event provides logging for some event (backup, restore)

func (*Event) Debug

func (e *Event) Debug(msg string, args ...interface{})

func (*Event) Error

func (e *Event) Error(msg string, args ...interface{})

func (*Event) Fatal

func (e *Event) Fatal(msg string, args ...interface{})

func (*Event) Info

func (e *Event) Info(msg string, args ...interface{})

func (*Event) Warning

func (e *Event) Warning(msg string, args ...interface{})

type LogEntry

type LogEntry struct {
	ObjID   primitive.ObjectID `bson:"-" json:"-"` // to get sense of mgs total ordering while reading logs
	Time    string             `bson:"-" json:"t"`
	TS      int64              `bson:"ts" json:"-"`
	Tns     int                `bson:"ns" json:"-"`
	TZone   int                `bson:"tz" json:"-"`
	LogKeys `bson:",inline" json:",inline"`
	Msg     string `bson:"msg" json:"msg"`
}

func (*LogEntry) String

func (e *LogEntry) String() (s string)

func (*LogEntry) StringNode

func (e *LogEntry) StringNode() (s string)

type LogKeys

type LogKeys struct {
	Severity Severity            `bson:"s" json:"s"`
	RS       string              `bson:"rs" json:"rs"`
	Node     string              `bson:"node" json:"node"`
	Event    string              `bson:"e" json:"e"`
	ObjName  string              `bson:"eobj" json:"eobj"`
	Epoch    primitive.Timestamp `bson:"ep,omitempty" json:"ep,omitempty"`
	OPID     string              `bson:"opid,omitempty" json:"opid,omitempty"`
}

type LogRequest

type LogRequest struct {
	TimeMin time.Time
	TimeMax time.Time
	LogKeys
}

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func New

func New(cn *mongo.Collection, rs, node string) *Logger

func (*Logger) Debug

func (l *Logger) Debug(event string, obj, opid string, epoch primitive.Timestamp, msg string, args ...interface{})

func (*Logger) Error

func (l *Logger) Error(event string, obj, opid string, epoch primitive.Timestamp, msg string, args ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(event string, obj, opid string, epoch primitive.Timestamp, msg string, args ...interface{})

func (*Logger) Get

func (l *Logger) Get(r *LogRequest, limit int64, exactSeverity bool) ([]LogEntry, error)

func (*Logger) Info

func (l *Logger) Info(event string, obj, opid string, epoch primitive.Timestamp, msg string, args ...interface{})

func (*Logger) NewEvent

func (l *Logger) NewEvent(typ, name, opid string, epoch primitive.Timestamp) *Event

func (*Logger) Output

func (l *Logger) Output(e *LogEntry) error

func (*Logger) PrintLogs

func (l *Logger) PrintLogs(to io.Writer, f OutFormat, r *LogRequest, limit int64, showNode bool) error

func (*Logger) Printf

func (l *Logger) Printf(msg string, args ...interface{})

func (*Logger) SetOut

func (l *Logger) SetOut(w io.Writer)

SetOut set io output for the logs

func (*Logger) Warning

func (l *Logger) Warning(event string, obj, opid string, epoch primitive.Timestamp, msg string, args ...interface{})

type OutFormat

type OutFormat int
const (
	FormatText OutFormat = iota
	FormatJSON
)

type Severity

type Severity int
const (
	Fatal Severity = iota
	Error
	Warning
	Info
	Debug
)

func (Severity) String

func (s Severity) String() string

Jump to

Keyboard shortcuts

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