logger

package
Version: v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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(verbosity string)

SetLogLevel is used to set log level

type CallerHook

type CallerHook struct{}

CallerHook implements zerolog.Hook interface.

func (CallerHook) Run

func (h CallerHook) Run(e *zerolog.Event, level zerolog.Level, msg string)

Run adds additional context

type Config

type Config struct {
	Pretty bool
	Level  string
}

Config defines the config structure

func NewConfig

func NewConfig() *Config

NewConfig is used to init config with default values

func (*Config) RegisterFlagsWithPrefix

func (c *Config) RegisterFlagsWithPrefix(prefix string, f *pflag.FlagSet)

RegisterFlagsWithPrefix is used to register flags

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(verbosity string)
}

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

Source Files

Jump to

Keyboard shortcuts

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