logger

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetStandardLogger

func SetStandardLogger(l Logger)

SetStandardLogger sets the global logger's output to a custom logger instance.

Types

type Config

type Config struct {
	// Format specifies the output log format.
	// Accepted values are: json, text(default).
	Format string

	// Level is the minimum log level that should appear on the output.
	Level string

	// NoColor makes sure that no log output gets colorized.
	NoColor bool
}

Config holds details necessary for logging.

type Logger

type Logger interface {
	logur.Logger

	// Format strings
	Tracef(format string, args ...interface{})
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})

	// WithFields returns a new logger with fields added to the current logger.
	WithFields(fields map[string]interface{}) Logger

	// WithField is a shortcut for WithFields(map[string]interface{}{key: value}).
	WithField(key string, value interface{}) Logger

	// WithContext = Ctx 从context中读取request_id
	Ctx(ctx context.Context) Logger

	// WithError = Err returns a new logger with the given error added to the current logger.
	Err(err error) Logger
}

func New

func New(config Config) Logger

New creates a new logger.

Jump to

Keyboard shortcuts

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