logger

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LevelDebug = Level{Name: "debug", Color: color.FgWhite, Index: 0, Writer: os.Stdout}
	LevelInfo  = Level{Name: "info", Color: color.FgWhite, Index: 1, Writer: os.Stdout}
	LevelWarn  = Level{Name: "warn", Color: color.FgYellow, Index: 2, Writer: os.Stderr}
	LevelError = Level{Name: "error", Color: color.FgHiRed, Index: 3, Writer: os.Stderr}
	LevelFatal = Level{Name: "fatal", Color: color.FgRed, Index: 4, Writer: os.Stderr}
)

defines a set of log level

Functions

This section is empty.

Types

type BasicLogger

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

BasicLogger simply implements Logger

func (*BasicLogger) LogDebug

func (b *BasicLogger) LogDebug(fields map[string]interface{}, format string, args ...interface{})

LogDebug print a message with debug level.

func (*BasicLogger) LogError

func (b *BasicLogger) LogError(fields map[string]interface{}, format string, args ...interface{})

LogError print a message with error level.

func (*BasicLogger) LogFatal

func (b *BasicLogger) LogFatal(fields map[string]interface{}, format string, args ...interface{})

LogFatal print a message with fatal level.

func (*BasicLogger) LogInfo

func (b *BasicLogger) LogInfo(fields map[string]interface{}, format string, args ...interface{})

LogInfo print a message with info level.

func (*BasicLogger) LogWarn

func (b *BasicLogger) LogWarn(fields map[string]interface{}, format string, args ...interface{})

LogWarn print a message with warn level.

func (*BasicLogger) NewLogger

func (b *BasicLogger) NewLogger(component string) Logger

NewLogger is used to derive a new child Logger

func (*BasicLogger) SetLogLevel

func (b *BasicLogger) SetLogLevel(level Level) Logger

SetLogLevel is used to set log level

type Config

type Config struct {
	Pretty bool
	Level  Level
}

Config defines the config structure

func NewConfig

func NewConfig() *Config

NewConfig is used to init config with default values

type Level

type Level struct {
	Name   string
	Color  color.Attribute
	Index  int
	Writer io.Writer
}

Level is the structure of log level

type Logger

type Logger interface {
	// LogDebug print a message with debug level.
	LogDebug(fields map[string]interface{}, format string, args ...interface{})
	// LogInfo print a message with info level.
	LogInfo(fields map[string]interface{}, format string, args ...interface{})
	// LogWarn print a message with warn level.
	LogWarn(fields map[string]interface{}, format string, args ...interface{})
	// LogError print a message with error level.
	LogError(fields map[string]interface{}, format string, args ...interface{})
	// LogFatal print a message with fatal level.
	LogFatal(fields map[string]interface{}, format string, args ...interface{})
	// NewLogger is used to derive a new child Logger
	NewLogger(component string) Logger
	// SetLogLevel is used to set log level
	SetLogLevel(level Level) Logger
}

Logger defines the basic log library implementation

func New

func New(cfg *Config, component string, registerer prometheus.Registerer) (Logger, error)

New is used to init service

func NewDefault

func NewDefault(component string) Logger

NewDefault is used to initialize a simple Logger

Jump to

Keyboard shortcuts

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