log

package
v0.0.533 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLogrusEntry

func GetLogrusEntry(l Logger) (*logrus.Entry, error)

func SetDefault

func SetDefault(logger Logger)

func WithLogger

func WithLogger(ctx context.Context, logger Logger) context.Context

Types

type Fields

type Fields map[string]interface{}

type Logger

type Logger interface {
	Printf(string, ...interface{})
	Debug(...interface{})
	Info(...interface{})
	Warn(...interface{})
	Fatal(...interface{})
	Error(...interface{})
	Debugf(string, ...interface{})
	Infof(string, ...interface{})
	Warnf(string, ...interface{})
	Fatalf(string, ...interface{})
	Errorf(string, ...interface{})

	WithField(string, interface{}) Logger
	WithFields(Fields) Logger
	WithError(error) Logger

	// AddPFlags adds persistent logger flags to cmd
	AddPFlags(*cobra.Command)
}
var (
	G = GetLogger

	L Logger = NopLogger{}
)

func FromLogrus

func FromLogrus(l *logrus.Entry, c *LogrusConfig) Logger

func GetLogger

func GetLogger(ctx ...context.Context) Logger

type LogrusConfig

type LogrusConfig struct {
	Level  string
	Format LogrusFormatter
}

type LogrusFormatter

type LogrusFormatter string
const (
	FormatterText LogrusFormatter = defaultFormatter
	FormatterJSON LogrusFormatter = "json"
)

type NopLogger

type NopLogger struct{}

func (NopLogger) AddPFlags

func (NopLogger) AddPFlags(*cobra.Command)

func (NopLogger) Debug

func (NopLogger) Debug(...interface{})

func (NopLogger) Debugf

func (NopLogger) Debugf(string, ...interface{})

func (NopLogger) Error

func (NopLogger) Error(...interface{})

func (NopLogger) Errorf

func (NopLogger) Errorf(string, ...interface{})

func (NopLogger) Fatal

func (NopLogger) Fatal(...interface{})

func (NopLogger) Fatalf

func (NopLogger) Fatalf(string, ...interface{})

func (NopLogger) Info

func (NopLogger) Info(...interface{})

func (NopLogger) Infof

func (NopLogger) Infof(string, ...interface{})

func (NopLogger) Printf

func (NopLogger) Printf(string, ...interface{})

func (NopLogger) Warn

func (NopLogger) Warn(...interface{})

func (NopLogger) Warnf

func (NopLogger) Warnf(string, ...interface{})

func (NopLogger) WithError

func (l NopLogger) WithError(error) Logger

func (NopLogger) WithField

func (l NopLogger) WithField(string, interface{}) Logger

func (NopLogger) WithFields

func (l NopLogger) WithFields(Fields) Logger

Jump to

Keyboard shortcuts

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