utils

package
v1.0.0-rc.21 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DiscardEntry = logrus.NewEntry(DiscardLog)
View Source
var DiscardLog = &logrus.Logger{
	Out:          io.Discard,
	Hooks:        make(logrus.LevelHooks),
	Formatter:    new(NullFormatter),
	Level:        logrus.PanicLevel,
	ExitFunc:     os.Exit,
	ReportCaller: false,
}

Functions

func FormatAppInfoHeader

func FormatAppInfoHeader(name, version, build string) string

func GetLogger added in v1.0.0

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

func GetModulePath added in v1.0.0

func GetModulePath(ctx context.Context) string

func GetTaskId added in v1.0.0

func GetTaskId(ctx context.Context) uint64

func NewLog

func NewLog(cfg config.Log) *logrus.Entry

func NewRand added in v1.0.0

func NewRand(clock Clock) *rand.Rand

NewRand returns a new Rand that uses a locked rand.Source.

The Go rand.Source interface is not safe for concurrent use:

- Docs: https://golang.org/pkg/math/rand/#Source - Discuss: https://github.com/golang/go/issues/3611 - Solution: https://github.com/mesosphere/mesos-dns/pull/317

func WithField added in v1.0.0

func WithField(ctx context.Context, key string, value interface{}) context.Context

func WithFields added in v1.0.0

func WithFields(ctx context.Context, fields logrus.Fields) context.Context

func WithLogger added in v1.0.0

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

func WithModule added in v1.0.0

func WithModule(ctx context.Context, module string) context.Context

func WithTaskId added in v1.0.0

func WithTaskId(ctx context.Context) context.Context

Types

type Clock added in v1.0.0

type Clock interface {
	After(d time.Duration) <-chan time.Time
	Now() time.Time
}
var ImmediatelyClock Clock = immediatelyClock{}
var NeverClock Clock = neverClock{}
var RealClock Clock = realClock{}

type NullFormatter added in v1.0.0

type NullFormatter struct{}

func (*NullFormatter) Format added in v1.0.0

func (*NullFormatter) Format(*logrus.Entry) ([]byte, error)

type PrinterDevNull

type PrinterDevNull struct{}

func (PrinterDevNull) Print

func (p PrinterDevNull) Print(string, string, string)

type PrinterLog

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

func NewPrinterLog

func NewPrinterLog(log *logrus.Entry, gameId int) *PrinterLog

func (*PrinterLog) Print

func (p *PrinterLog) Print(level, what, message string)

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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