log

package module
v0.0.0-...-bb01aa7 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: MIT Imports: 7 Imported by: 6

Documentation

Index

Constants

View Source
const (
	LoggerKey    = "logger"
	KindKey      = "kind"
	ComponentKey = "component"
)

Variables

This section is empty.

Functions

func RegisterLevelName

func RegisterLevelName(level Level, name string)

RegisterLevelName register the name of one level. If the level is already exists, the function will overwrite it. If the name given is empty, it register nothing, or it deregister a level name.

func ResetLevelNames

func ResetLevelNames()

ResetLevelNames reset level name to default.

Types

type Field

type Field struct {
	Key   string
	Value interface{}
}

Field is a marshaling operation used to add a key-value pair to a logger's context.

type Level

type Level int8

A Level is a logging priority. Higher levels are more important.

const (
	// DebugLevel logs are typically voluminous, and are usually disabled in
	// production.
	DebugLevel Level = iota - 1
	// InfoLevel is the default logging priority.
	InfoLevel
	// WarnLevel logs are more important than Info, but don't need individual
	// human review.
	WarnLevel
	// ErrorLevel logs are high-priority. If an application is running smoothly,
	// it shouldn't generate any error-level logs.
	ErrorLevel
	// ClosedLevel logs output nothing.
	ClosedLevel = math.MaxInt8
)

func (Level) String

func (l Level) String() string

String returns a lower-case ASCII representation of the log level.

type Logger

type Logger interface {
	Print(v ...interface{})
	Printf(format string, v ...interface{})
	Println(v ...interface{})
	LevelEnabled(level Level) bool
	With(field ...Field) Logger
	AtLevel(level Level) Logger
}

Logger represents a logger with level, fields, ect.

func DefaultStd

func DefaultStd() Logger

func NewStd

func NewStd(stdLogger *stdlog.Logger, options ...Option) Logger

NewStd new Logger with options.

type Option

type Option func(l *logger)

func AtLevel

func AtLevel(level Level) Option

func WithFields

func WithFields(fields ...Field) Option

Jump to

Keyboard shortcuts

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