log

package
v1.8.1-0...-0157f87 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 18 Imported by: 3

Documentation

Index

Constants

View Source
const (
	F = "F"
	E = "E"
	W = "W"
	I = "I"
	D = "D"
)
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

View Source
var (
	DiscardLogger = &discardLoggerImpl{}
	DiscardEvent  = &discardEventImpl{}
)

Functions

func AsLocal

func AsLocal(ts int64) string

func AsUTC

func AsUTC(ts int64) string

func CommandLastError

func CommandLastError(ctx context.Context, cc connect.Client, cid string) (string, error)

func Copy

func Copy(to, from context.Context) context.Context

func Follow

func Follow(
	ctx context.Context,
	conn connect.Client,
	r *LogRequest,
	exactSeverity bool,
) (<-chan *Entry, <-chan error)

func GetFirstTSForOPID

func GetFirstTSForOPID(ctx context.Context, conn connect.Client, opid string) (int64, error)

func GetLastTSForOPID

func GetLastTSForOPID(ctx context.Context, conn connect.Client, opid string) (int64, error)

func SetLogEventToContext

func SetLogEventToContext(ctx context.Context, ev LogEvent) context.Context

func SetLoggerToContext

func SetLoggerToContext(ctx context.Context, ev Logger) context.Context

Types

type Buffer

type Buffer interface {
	io.Writer
	Flush() error
}

type Cursor

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

func CommandLogCursor

func CommandLogCursor(
	ctx context.Context,
	conn connect.Client,
	opid string,
) (*Cursor, error)

func (*Cursor) Close

func (c *Cursor) Close(ctx context.Context) error

func (*Cursor) Err

func (c *Cursor) Err() error

func (*Cursor) Next

func (c *Cursor) Next(ctx context.Context) bool

func (*Cursor) Record

func (c *Cursor) Record() (*Entry, error)

type Entries added in v1.6.0

type Entries struct {
	Data     []Entry `json:"data"`
	ShowNode bool    `json:"-"`
	Extr     bool    `json:"-"`
	// contains filtered or unexported fields
}

func LogGet

func LogGet(ctx context.Context, m connect.Client, r *LogRequest, limit int64) (*Entries, error)

func LogGetExactSeverity

func LogGetExactSeverity(ctx context.Context, m connect.Client, r *LogRequest, limit int64) (*Entries, error)

func (Entries) MarshalJSON added in v1.6.0

func (e Entries) MarshalJSON() ([]byte, error)

func (*Entries) SetLocation

func (e *Entries) SetLocation(l string) error

func (Entries) String added in v1.6.0

func (e Entries) String() string

type Entry added in v1.6.0

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

func (*Entry) String added in v1.6.0

func (e *Entry) String() string

func (*Entry) StringNode added in v1.6.0

func (e *Entry) StringNode() string

func (*Entry) Stringify

func (e *Entry) Stringify(f tsFormatFn, showNode, extr bool) string

type LogEvent

type LogEvent interface {
	Debug(msg string, args ...any)
	Info(msg string, args ...any)
	Warning(msg string, args ...any)
	Error(msg string, args ...any)
	Fatal(msg string, args ...any)
}

func LogEventFromContext

func LogEventFromContext(ctx context.Context) LogEvent

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 interface {
	NewEvent(typ, name, opid string, epoch primitive.Timestamp) LogEvent
	NewDefaultEvent() LogEvent

	Close()

	SefBuffer(Buffer)

	PauseMgo()
	ResumeMgo()

	Write(p []byte) (n int, err error)

	Printf(msg string, args ...any)
	Debug(event, obj, opid string, epoch primitive.Timestamp, msg string, args ...any)
	Info(event, obj, opid string, epoch primitive.Timestamp, msg string, args ...any)
	Warning(event, obj, opid string, epoch primitive.Timestamp, msg string, args ...any)
	Error(event, obj, opid string, epoch primitive.Timestamp, msg string, args ...any)
	Fatal(event, obj, opid string, epoch primitive.Timestamp, msg string, args ...any)
	Output(ctx context.Context, e *Entry) error
}

func FromContext

func FromContext(ctx context.Context) Logger

func New

func New(conn connect.Client, rs, node string) Logger

New creates default logger which outputs to stderr.

func NewWithOpts

func NewWithOpts(conn connect.Client, rs, node string, opts *Opts) Logger

NewWithOpts creates logger based on provided options.

type Opts

type Opts struct {
	LogPath  string
	LogJSON  bool
	LogLevel string
}

Opts represents options that are specified by the user.

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