log

package module
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: MIT Imports: 5 Imported by: 2

README

Go Reference

Documentation

Index

Constants

View Source
const (
	AppName    = "app_name"
	AppVersion = "app_version"
)
View Source
const (
	DebugLevel = iota
	InfoLevel
	WarnLevel
	ErrorLevel
	PanicLevel
)

Variables

This section is empty.

Functions

func Debug

func Debug(ctx context.Context, msg string, keysAndValues ...interface{})

func Dump

func Dump(msg string, v ...interface{})

Dump should be used only during development and should not stay in production code.

func Error

func Error(ctx context.Context, msg string, keysAndValues ...interface{})

func Info

func Info(ctx context.Context, msg string, keysAndValues ...interface{})

func IsDebug

func IsDebug(ctx context.Context) bool

func Panic

func Panic(ctx context.Context, msg string, keysAndValues ...interface{})

func SetGlobalLogger

func SetGlobalLogger(l Logger)

SetGlobalLogger sets the Logger instance used in global scope. Must be called during initialization as early as possible. It's not thread safe.

func Truncate

func Truncate(str string, length int, concat string) string

func Warn

func Warn(ctx context.Context, msg string, keysAndValues ...interface{})

Types

type ContextMapper

type ContextMapper interface {
	Values(ctx context.Context) map[string]string
}

ContextMapper is an interface that returns Values which should be included in the log fields.

type Logger

type Logger interface {
	Debug(ctx context.Context, msg string, keysAndValues ...interface{})
	Info(ctx context.Context, msg string, keysAndValues ...interface{})
	Warn(ctx context.Context, msg string, keysAndValues ...interface{})
	Error(ctx context.Context, msg string, keysAndValues ...interface{})
	Panic(ctx context.Context, msg string, keysAndValues ...interface{})
	IsDebug(ctx context.Context) bool
	// Dump should be used only during development and should not stay in production code.
	Dump(msg string, v ...interface{})
}

Logger is an interface that wraps the most common logging methods. Correlation related information like the Correlation-Id and Workflow-Id will be extracted from the passed Context.

func GlobalLogger

func GlobalLogger() Logger

GlobalLogger gets the Logger instance used in global scope. It's not thread safe.

type ThrottleLogger

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

func Throttle

func Throttle(logger Logger, interval time.Duration) (*ThrottleLogger, chan struct{})

func (*ThrottleLogger) Debug

func (t *ThrottleLogger) Debug(ctx context.Context, msg string, keysAndValues ...interface{})

func (*ThrottleLogger) Dump

func (t *ThrottleLogger) Dump(msg string, v ...interface{})

Dump should be used only during development and should not stay in production code.

func (*ThrottleLogger) Error

func (t *ThrottleLogger) Error(ctx context.Context, msg string, keysAndValues ...interface{})

func (*ThrottleLogger) Flush

func (t *ThrottleLogger) Flush()

func (*ThrottleLogger) Info

func (t *ThrottleLogger) Info(ctx context.Context, msg string, keysAndValues ...interface{})

func (*ThrottleLogger) IsDebug

func (t *ThrottleLogger) IsDebug(ctx context.Context) bool

func (*ThrottleLogger) Panic

func (t *ThrottleLogger) Panic(ctx context.Context, msg string, keysAndValues ...interface{})

func (*ThrottleLogger) Stop

func (t *ThrottleLogger) Stop()

func (*ThrottleLogger) Warn

func (t *ThrottleLogger) Warn(ctx context.Context, msg string, keysAndValues ...interface{})

Directories

Path Synopsis
Package color adds coloring functionality for TTY output.
Package color adds coloring functionality for TTY output.

Jump to

Keyboard shortcuts

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