log

package
v0.1.0-alpha3 Latest Latest
Warning

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

Go to latest
Published: May 18, 2021 License: MIT Imports: 9 Imported by: 1

README

log

  • Buildin go standard log package support.
  • kita-zap: Zap adaptation
  • kita-logrus: Logrus adaptation. TBD

Documentation

Index

Constants

View Source
const (
	LevelKey     = "level"
	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.

func UseManager

func UseManager(mng Manager)

Types

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 {
	LevelEnabled(level Level) bool
	Printer() Printer
	Name() string
	AtLevel(level Level) Printer
}

Logger represents a logger that can provide Printers.

func Get

func Get(name string) Logger

type Manager

type Manager interface {
	Get(name string) Logger
	Level(name string, level Level)
}

Manager represents a Logger manager. It provide Loggers by logger name.

func GetManager

func GetManager() (Manager, error)

func NewStdManager

func NewStdManager(logger *stdlog.Logger, opts ...Option) Manager

type Option

type Option func(m *manager)

func LoggerLevel

func LoggerLevel(name string, level Level) Option

func RootLevel

func RootLevel(level Level) Option

type Printer

type Printer interface {
	Print(v ...interface{})
	Printf(format string, v ...interface{})
	Println(v ...interface{})
	With(key string, value interface{}) Printer
}

Printer represents a stateful printer that is at specific level, carries fields including logger name. A Printer is usually got from a Logger and left/throw away after do print.

Jump to

Keyboard shortcuts

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