logger

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// L is an alias for the standard logger.
	L = logrus.NewEntry(NewLogger())
)

Functions

func FromContext

func FromContext(ctx context.Context) *logrus.Entry

FromContext gets logger from context. In case of no logger in context, the default logger is returned.

func NewLogger

func NewLogger() *logrus.Logger

NewLogger returns a new logger.

func WithLogger

func WithLogger(ctx context.Context, logger *logrus.Entry) context.Context

WithLogger returns a new context with the provided logger. Use in combination with logger.WithField(s) for great effect.

Types

type EasyFormatter

type EasyFormatter struct{}

func (*EasyFormatter) Format

func (f *EasyFormatter) Format(entry *logrus.Entry) ([]byte, error)

The Formatter interface is used to implement a custom Formatter. It takes an `Entry`. It exposes all the fields, including the default ones:

* `entry.Data["msg"]`. The message passed from Info, Warn, Error .. * `entry.Data["time"]`. The timestamp. * `entry.Data["level"]. The level the entry was logged at.

Any additional fields added with `WithField` or `WithFields` are also in `entry.Data`. Format is expected to return an array of bytes which are then logged to `logger.Out`.

type Fields

type Fields = logrus.Fields

Fields type to pass to `WithFields`, alias from `logrus`.

func Field

func Field(fields map[string]interface{}) Fields

Jump to

Keyboard shortcuts

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