Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { EncodingConsole bool `env:"ENCODING_CONSOLE" default:"false" usage:"allows to set user-friendly formatting"` Level string `env:"LEVEL" default:"info" usage:"allows to set custom logger level"` Trace string `env:"TRACE" default:"fatal" usage:"allows to set custom trace level"` SampleRate *int `env:"SAMPLE_RATE" default:"1000" usage:"allows to set sample rate"` }
Config structure that provides configuration of logger module.
type Logger ¶
type Logger interface { Debug(...interface{}) Debugf(msg string, args ...interface{}) Debugw(msg string, keysAndValues ...interface{}) Info(...interface{}) Infof(msg string, args ...interface{}) Infow(msg string, keysAndValues ...interface{}) Warn(...interface{}) Warnf(msg string, args ...interface{}) Warnw(msg string, keysAndValues ...interface{}) Error(...interface{}) Errorf(msg string, args ...interface{}) Errorw(msg string, keysAndValues ...interface{}) Fatal(...interface{}) Fatalf(msg string, args ...interface{}) Fatalw(msg string, keysAndValues ...interface{}) Panic(...interface{}) Panicf(msg string, args ...interface{}) Panicw(msg string, keysAndValues ...interface{}) With(...interface{}) Logger Named(string) Logger Sugar() *SugaredLogger Std() *log.Logger Sync() error }
Logger common interface.
type Option ¶
type Option func(*logger)
Option allows to set custom logger settings.
func WithAppName ¶
WithAppName allows to set application name to logger fields.
func WithAppVersion ¶
WithAppVersion allows to set application version to logger fields.
func WithConsoleColored ¶
func WithConsoleColored() Option
WithConsoleColored allows to set colored console output.
func WithCustomLevel ¶
func WithCustomLevel(v zap.AtomicLevel) Option
WithCustomLevel allows to pass custom level, that can be changed at any time. For example take a look https://github.com/uber-go/zap/blob/master/http_handler.go#L33.
func WithCustomOutput ¶
WithCustomOutput allows to set custom output for Logger.
func WithTimeKey ¶
WithTimeKey allows to set TimeKey for zapcore.EncoderConfig.
func WithZapOption ¶
WithZapOption allows to set zap.Option.
type SugaredLogger ¶
type SugaredLogger = zap.SugaredLogger
A SugaredLogger wraps the base Logger functionality in a slower, but less verbose, API. Any Logger can be converted to a SugaredLogger with its Sugar method. Type alias.
type WriteSyncer ¶
type WriteSyncer = zapcore.WriteSyncer
WriteSyncer is an io.Writer that can also flush any buffered data. Note that *os.File (and thus, os.Stderr and os.Stdout) implement WriteSyncer. Type alias.