logger

package
v0.0.0-...-3511abf Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogrusLevelToProto

func LogrusLevelToProto(l logrus.Level) logv1.LogLevel

LogrusLevelToProto translates a logrus level to a our protobuf log levels.

func New

func New() echo.Logger

New returns an echo logger connected to logrus.

func SetLogrus

func SetLogrus(c Config)

SetLogrus sets logrus globally.

Types

type Config

type Config struct {
	Level string `json:"level"`
	Color bool   `json:"color"`
}

Config is the configuration of logger.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration of logger.

func (Config) Validate

func (c Config) Validate() []error

Validate implements the check.Validatable interface.

type Context

type Context logrus.Fields

Context maintains context on logging fields to aid stitching together a history.

func MergeContexts

func MergeContexts(xs ...Context) Context

MergeContexts returns a new merged Context object from the inputs, preferring later inputs.

func (Context) Fields

func (c Context) Fields() logrus.Fields

Fields returns the context's logrus.Fields to enrich a log.

type EntriesBatch

type EntriesBatch []*Entry

EntriesBatch is a batch of logger.Entry.

func (EntriesBatch) ForEach

func (eb EntriesBatch) ForEach(f func(interface{}) error) error

ForEach implements logs.Batch.

func (EntriesBatch) Size

func (eb EntriesBatch) Size() int

Size implements logs.Batch.

type Entry

type Entry struct {
	ID      int          `json:"id"`
	Message string       `json:"message"`
	Time    time.Time    `json:"time"`
	Level   logrus.Level `json:"level"`
}

Entry captures the interesting attributes of logrus.Entry.

type LogBuffer

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

LogBuffer is an in-memory buffer based logger.

func NewLogBuffer

func NewLogBuffer(capacity int) *LogBuffer

NewLogBuffer creates a new LogBuffer.

func (*LogBuffer) Entries

func (lb *LogBuffer) Entries(startID int, endID int, limit int) []*Entry

Entries retrieves a snapshot of the newest logged entries.

  • startID: Beginning of the range of IDs to include (inclusive).
  • endID: End of the range of IDs to include (exclusive).
  • limit: Maximum number of entries to return.

Special cases:

  • startID == -1: Don't limit the minimum ID.
  • endID == -1: Don't limit the maximum ID.
  • limit == -1: Don't limit the number of entries.

func (*LogBuffer) Fire

func (lb *LogBuffer) Fire(entry *logrus.Entry) error

Fire implements the logrus.Hook interface.

func (*LogBuffer) Len

func (lb *LogBuffer) Len() int

Len returns the total number of entries written to the buffer.

func (*LogBuffer) Levels

func (lb *LogBuffer) Levels() []logrus.Level

Levels implements the logrus.Hook interface.

Jump to

Keyboard shortcuts

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