logger

package
v1.0.0-beta.27 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DPanic

func DPanic(args ...interface{})

DPanic uses fmt.Sprint to construct and log a message. In development, the logger then panics. (See DPanicLevel for details.)

func DPanicf

func DPanicf(template string, args ...interface{})

DPanicf uses fmt.Sprintf to log a templated message. In development, the logger then panics. (See DPanicLevel for details.)

func DPanicw

func DPanicw(msg string, keysAndValues ...interface{})

DPanicw logs a message with some additional context. In development, the logger then panics. (See DPanicLevel for details.) The variadic key-value pairs are treated as they are in With.

func Debug

func Debug(args ...interface{})

Debug uses fmt.Sprint to construct and log a message.

func Debugf

func Debugf(template string, args ...interface{})

Debugf uses fmt.Sprintf to log a templated message.

func Debugw

func Debugw(msg string, keysAndValues ...interface{})

Debugw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.

When debug-level logging is disabled, this is much faster than

s.With(keysAndValues).Debug(msg)

func Desugar

func Desugar() *zap.Logger

Desugar unwraps a SugaredLogger, exposing the original Logger. Desugaring is quite inexpensive, so it's reasonable for a single application to use both Loggers and SugaredLoggers, converting between them on the boundaries of performance-sensitive code.

func Error

func Error(args ...interface{})

Error uses fmt.Sprint to construct and log a message.

func Errorf

func Errorf(template string, args ...interface{})

Errorf uses fmt.Sprintf to log a templated message.

func Errorw

func Errorw(msg string, keysAndValues ...interface{})

Errorw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.

func Fatal

func Fatal(args ...interface{})

Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit.

func Fatalf

func Fatalf(template string, args ...interface{})

Fatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.

func Fatalw

func Fatalw(msg string, keysAndValues ...interface{})

Fatalw logs a message with some additional context, then calls os.Exit. The variadic key-value pairs are treated as they are in With.

func Info

func Info(args ...interface{})

Info uses fmt.Sprint to construct and log a message.

func Infof

func Infof(template string, args ...interface{})

Infof uses fmt.Sprintf to log a templated message.

func Infow

func Infow(msg string, keysAndValues ...interface{})

Infow logs a message with some additional context. The variadic key-value pairs are treated as they are in With.

func Named

func Named(name string) *zap.SugaredLogger

Named adds a sub-scope to the logger's name. See Logger.Named for details.

func Panic

func Panic(args ...interface{})

Panic uses fmt.Sprint to construct and log a message, then panics.

func Panicf

func Panicf(template string, args ...interface{})

Panicf uses fmt.Sprintf to log a templated message, then panics.

func Panicw

func Panicw(msg string, keysAndValues ...interface{})

Panicw logs a message with some additional context, then panics. The variadic key-value pairs are treated as they are in With.

func Trace

func Trace(ctx context.Context) *zap.SugaredLogger

Trace logs a message with trace prefix and return *zap.SugaredLogger.

func TraceRaw

func TraceRaw(ctx context.Context) *zap.Logger

TraceRaw logs a message with trace prefix and return *zap.Logger.

func Warn

func Warn(args ...interface{})

Warn uses fmt.Sprint to construct and log a message.

func Warnf

func Warnf(template string, args ...interface{})

Warnf uses fmt.Sprintf to log a templated message.

func Warnw

func Warnw(msg string, keysAndValues ...interface{})

Warnw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.

Types

type Config

type Config struct {
	Level             zap.AtomicLevel        `config:"level" json:"level" desc:"debug,info,warn,error,dpanic,panic,fatal"`
	Development       bool                   `config:"development" json:"development"`
	DisableCaller     bool                   `config:"disableCaller" json:"disableCaller"`
	DisableStacktrace bool                   `config:"disableStacktrace" json:"disableStacktrace"`
	Sampling          *SamplingConfig        `config:"sampling" json:"sampling"`
	Encoding          string                 `config:"encoding" json:"encoding"`
	EncoderConfig     *EncoderConfig         `config:"encoderConfig" json:"encoderConfig"`
	OutputPaths       []string               `config:"outputPaths" json:"outputPaths"`
	ErrorOutputPaths  []string               `config:"errorOutputPaths" json:"errorOutputPaths"`
	InitialFields     map[string]interface{} `config:"initialFields" json:"initialFields"`
	// contains filtered or unexported fields
}

Config of logger

func DefaultConfig added in v1.0.0

func DefaultConfig(key string) *Config

DefaultConfig of logger

func StdConfig added in v1.0.0

func StdConfig(key string) *Config

StdConfig new a logger from config path "logger.{{name}}"

func (*Config) Build added in v1.0.0

func (cfg *Config) Build() (*Logger, error)

Build a logger

func (*Config) Path added in v1.0.0

func (cfg *Config) Path() string

type EncoderConfig added in v1.0.0

type EncoderConfig struct {
	MessageKey     string `config:"messageKey" json:"messageKey"`
	LevelKey       string `config:"levelKey" json:"levelKey"`
	TimeKey        string `config:"timeKey" json:"timeKey"`
	NameKey        string `config:"nameKey" json:"nameKey"`
	CallerKey      string `config:"callerKey" json:"callerKey"`
	StacktraceKey  string `config:"stacktraceKey" json:"stacktraceKey"`
	LineEnding     string `config:"lineEnding" json:"lineEnding"`
	EncodeLevel    string `config:"levelEncoder" json:"levelEncoder"`
	EncodeTime     string `config:"timeEncoder" json:"timeEncoder"`
	EncodeDuration string `config:"durationEncoder" json:"durationEncoder"`
	EncodeCaller   string `config:"callerEncoder" json:"callerEncoder"`
	EncodeName     string `config:"nameEncoder" json:"nameEncoder"`
}

EncoderConfig of logger

type Logger

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

Logger logger option

func (*Logger) DPanic

func (logger *Logger) DPanic(args ...interface{})

func (*Logger) DPanicf

func (logger *Logger) DPanicf(template string, args ...interface{})

func (*Logger) DPanicw

func (logger *Logger) DPanicw(msg string, keysAndValues ...interface{})

func (*Logger) Debug

func (logger *Logger) Debug(args ...interface{})

func (*Logger) Debugf

func (logger *Logger) Debugf(template string, args ...interface{})

func (*Logger) Debugw

func (logger *Logger) Debugw(msg string, keysAndValues ...interface{})

func (*Logger) Desugar

func (logger *Logger) Desugar() *zap.Logger

func (*Logger) Error

func (logger *Logger) Error(args ...interface{})

func (*Logger) Errorf

func (logger *Logger) Errorf(template string, args ...interface{})

func (*Logger) Errorw

func (logger *Logger) Errorw(msg string, keysAndValues ...interface{})

func (*Logger) Fatal

func (logger *Logger) Fatal(args ...interface{})

func (*Logger) Fatalf

func (logger *Logger) Fatalf(template string, args ...interface{})

func (*Logger) Fatalw

func (logger *Logger) Fatalw(msg string, keysAndValues ...interface{})

func (*Logger) Info

func (logger *Logger) Info(args ...interface{})

func (*Logger) Infof

func (logger *Logger) Infof(template string, args ...interface{})

func (*Logger) Infow

func (logger *Logger) Infow(msg string, keysAndValues ...interface{})

func (*Logger) Named

func (logger *Logger) Named(name string) *zap.SugaredLogger

func (*Logger) Panic

func (logger *Logger) Panic(args ...interface{})

func (*Logger) Panicf

func (logger *Logger) Panicf(template string, args ...interface{})

func (*Logger) Panicw

func (logger *Logger) Panicw(msg string, keysAndValues ...interface{})

func (*Logger) String added in v1.0.0

func (logger *Logger) String() string

func (*Logger) Trace

func (logger *Logger) Trace(ctx context.Context) *zap.SugaredLogger

Trace logger with requestId and uid

func (*Logger) TraceRaw

func (logger *Logger) TraceRaw(ctx context.Context) *zap.Logger

func (*Logger) Warn

func (logger *Logger) Warn(args ...interface{})

func (*Logger) Warnf

func (logger *Logger) Warnf(template string, args ...interface{})

func (*Logger) Warnw

func (logger *Logger) Warnw(msg string, keysAndValues ...interface{})

type SamplingConfig added in v1.0.0

type SamplingConfig struct {
	Initial    int `config:"initial" json:"initial"`
	Thereafter int `config:"thereafter" json:"thereafter"`
}

SamplingConfig of logger

Jump to

Keyboard shortcuts

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