log

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllowedFormat

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

AllowedFormat is a settable identifier for the output format that the logger can have.

func (*AllowedFormat) Set

func (f *AllowedFormat) Set(s string) error

Set updates the value of the allowed format.

func (*AllowedFormat) String

func (f *AllowedFormat) String() string

type AllowedLevel

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

AllowedLevel is a settable identifier for the minimum level a log entry must be have.

func (*AllowedLevel) Set

func (l *AllowedLevel) Set(s string) error

Set updates the value of the allowed level.

func (*AllowedLevel) String

func (l *AllowedLevel) String() string

func (*AllowedLevel) UnmarshalYAML

func (l *AllowedLevel) UnmarshalYAML(unmarshal func(interface{}) error) error

type Config

type Config struct {
	Level  *AllowedLevel
	Format *AllowedFormat
}

Config is a struct containing configurable settings for the logger.

type DynamicLogger

type DynamicLogger struct {
	Base         log.Logger
	Leveled      log.Logger
	CurrentLevel *AllowedLevel
	// contains filtered or unexported fields
}

func NewDynamic

func NewDynamic(config *Config) *DynamicLogger

NewDynamic returns a new leveled logger. Each logged line will be annotated with a timestamp. The output always goes to stdout. Some properties can be changed, like the level.

func (*DynamicLogger) Log

func (l *DynamicLogger) Log(keyvals ...interface{}) error

Log implements log.Logger.

func (*DynamicLogger) SetLevel

func (l *DynamicLogger) SetLevel(lvl *AllowedLevel)

SetLevel changes the log level.

type Logger

type Logger interface {
	Log(keyvals ...interface{}) error
}

func Debug

func Debug(logger Logger) Logger

Debug returns a logger that includes a Key/DebugValue pair.

func Error

func Error(logger Logger) Logger

Error returns a logger that includes a Key/ErrorValue pair.

func Info

func Info(logger Logger) Logger

Info returns a logger that includes a Key/InfoValue pair.

func Warn

func Warn(logger Logger) Logger

Warn returns a logger that includes a Key/WarnValue pair.

func With

func With(logger Logger, keyvals ...interface{}) Logger

With wraps log.With.

func WithPrefix

func WithPrefix(logger Logger, keyvals ...interface{}) Logger

WithPrefix wraps log.WithPrefix.

func WithSuffix

func WithSuffix(logger Logger, keyvals ...interface{}) Logger

WithSuffix wraps log.WithSuffix.

type SimpleLogger

type SimpleLogger struct {
	Base    log.Logger
	Leveled log.Logger
}

func New

func New(config *Config) *SimpleLogger

New returns a new leveled logger. Each logged line will be annotated with a timestamp. The output always goes to stdout.

func (*SimpleLogger) Log

func (l *SimpleLogger) Log(keyvals ...interface{}) error

Log implements log.Logger.

Jump to

Keyboard shortcuts

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