logging

package module
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: MIT Imports: 9 Imported by: 1

README

logging

go logging normalized interface for logging and bridging between zap logger with std loggers

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatNames added in v1.1.1

func FormatNames() []string

func LevelNames added in v1.1.1

func LevelNames() []string

Types

type Format added in v1.1.0

type Format int
const (
	DefaultFormat        = FormatText
	FormatText    Format = iota
	FormatJSON
)

func FormatString added in v1.1.1

func FormatString(s string) (Format, error)

FormatString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func FormatValues added in v1.1.1

func FormatValues() []Format

FormatValues returns all values of the enum

func ParseFormat added in v1.1.1

func ParseFormat(s string) (Format, error)

func (Format) IsAFormat added in v1.1.1

func (i Format) IsAFormat() bool

IsAFormat returns "true" if the value is listed in the enum definition. "false" otherwise

func (Format) LogRUsFormatter added in v1.1.0

func (i Format) LogRUsFormatter() logrus.Formatter

func (Format) MarshalJSON added in v1.1.1

func (i Format) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Format

func (Format) MarshalText added in v1.1.1

func (i Format) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for Format

func (Format) MarshalYAML added in v1.1.1

func (i Format) MarshalYAML() (interface{}, error)

MarshalYAML implements a YAML Marshaler for Format

func (*Format) Scan added in v1.1.1

func (i *Format) Scan(value interface{}) error

func (Format) String added in v1.1.1

func (i Format) String() string

func (*Format) UnmarshalJSON added in v1.1.1

func (i *Format) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Format

func (*Format) UnmarshalText added in v1.1.1

func (i *Format) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for Format

func (*Format) UnmarshalYAML added in v1.1.1

func (i *Format) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements a YAML Unmarshaler for Format

func (Format) Value added in v1.1.1

func (i Format) Value() (driver.Value, error)

func (Format) ZapEncoder added in v1.1.0

func (i Format) ZapEncoder(cfg zapcore.EncoderConfig) zapcore.Encoder

type Level added in v1.1.0

type Level int
const (
	DefaultLevel       = LevelInfo
	LevelDebug   Level = iota
	LevelInfo
	LevelWarn
	LevelError
	LevelDPanic
	LevelPanic
	LevelFatal
)

func LevelLogRUs added in v1.1.0

func LevelLogRUs(l logrus.Level) Level

func LevelString added in v1.1.1

func LevelString(s string) (Level, error)

LevelString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func LevelValues added in v1.1.1

func LevelValues() []Level

LevelValues returns all values of the enum

func LevelZap added in v1.1.0

func LevelZap(l zapcore.Level) Level

func ParseLevel added in v1.1.1

func ParseLevel(s string) (Level, error)

func (Level) IsALevel added in v1.1.1

func (i Level) IsALevel() bool

IsALevel returns "true" if the value is listed in the enum definition. "false" otherwise

func (Level) LogRUs added in v1.1.0

func (i Level) LogRUs() logrus.Level

func (Level) MarshalJSON added in v1.1.1

func (i Level) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Level

func (Level) MarshalText added in v1.1.1

func (i Level) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for Level

func (Level) MarshalYAML added in v1.1.1

func (i Level) MarshalYAML() (interface{}, error)

MarshalYAML implements a YAML Marshaler for Level

func (*Level) Scan added in v1.1.1

func (i *Level) Scan(value interface{}) error

func (Level) String added in v1.1.1

func (i Level) String() string

func (*Level) UnmarshalJSON added in v1.1.1

func (i *Level) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Level

func (*Level) UnmarshalText added in v1.1.1

func (i *Level) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for Level

func (*Level) UnmarshalYAML added in v1.1.1

func (i *Level) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements a YAML Unmarshaler for Level

func (Level) Value added in v1.1.1

func (i Level) Value() (driver.Value, error)

func (Level) Zap added in v1.1.0

func (i Level) Zap() zapcore.Level

type Logger

type Logger interface {
	Output() WriteSyncer
	SetOutput(WriteSyncer)
	Debug(args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
	DPanic(args ...interface{})
	Panic(args ...interface{})
	Fatal(args ...interface{})
	Debugf(template string, args ...interface{})
	Infof(template string, args ...interface{})
	Warnf(template string, args ...interface{})
	Errorf(template string, args ...interface{})
	DPanicf(template string, args ...interface{})
	Panicf(template string, args ...interface{})
	Fatalf(template string, args ...interface{})
	Debugw(msg string, keysAndValues ...interface{})
	Infow(msg string, keysAndValues ...interface{})
	Warnw(msg string, keysAndValues ...interface{})
	Errorw(msg string, keysAndValues ...interface{})
	DPanicw(msg string, keysAndValues ...interface{})
	Panicw(msg string, keysAndValues ...interface{})
	Fatalw(msg string, keysAndValues ...interface{})
	StdLogger() *log.Logger
	Format() Format
	SetFormat(Format)
	Level() Level
	SetLevel(Level)
	LogRUsLogger() *logrus.Logger
	ZapLogger() *zap.Logger
	ZapSugaredLogger() *zap.SugaredLogger
	With(args ...interface{}) Logger
}

func NewLogger

func NewLogger(options ...Option) Logger

type Option

type Option func(*logger)

func WithFormat added in v1.1.0

func WithFormat(f Format) Option

func WithLevel added in v1.1.0

func WithLevel(lvl Level) Option

func WithOutput added in v1.1.0

func WithOutput(syncer WriteSyncer) Option

func WithPreset added in v1.1.0

func WithPreset(p Preset) Option

func WithZap

func WithZap(zapper *zap.Logger) Option

func WithZapAtomicLevel added in v1.1.0

func WithZapAtomicLevel(atomicLevel zap.AtomicLevel) Option

func WithZapSugared added in v1.0.0

func WithZapSugared(sugar *zap.SugaredLogger) Option

type Preset added in v1.1.0

type Preset int
const (
	DefaultPreset            = PresetProduction
	PresetDevelopment Preset = iota
	PresetProduction
)

func (Preset) ZapEncoderConfig added in v1.1.0

func (i Preset) ZapEncoderConfig() zapcore.EncoderConfig

type WriteSyncer added in v1.1.0

type WriteSyncer = zapcore.WriteSyncer

Jump to

Keyboard shortcuts

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