Documentation ¶
Index ¶
- Constants
- func ApplyConfig() (err error)
- func Debug(message string, args ...interface{})
- func Debugw(message string, keyValues ...interface{})
- func Error(message string, args ...interface{})
- func Errorw(message string, keyValues ...interface{})
- func Fatal(message string, args ...interface{})
- func Fatalw(message string, keyValues ...interface{})
- func GetLoggerConfig() zap.Config
- func GoogleLevelEncoder(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
- func Info(message string, args ...interface{})
- func Infow(message string, keyValues ...interface{})
- func Panic(message string, args ...interface{})
- func Panicw(message string, keyValues ...interface{})
- func Print(v ...interface{})
- func Printf(format string, v ...interface{})
- func Println(v ...interface{})
- func SetErrorOutput(errorOutput string)
- func SetFormatter(encoding string, encoderConfig zapcore.EncoderConfig)
- func SetLevel(level zapcore.Level)
- func SetOutput(output string)
- func Warn(message string, args ...interface{})
- func Warning(message string, args ...interface{})
- func Warnw(message string, keyValues ...interface{})
- func With(args ...interface{})
- type Chain
- type Entry
- func (c *Entry) Copy() Chain
- func (c *Entry) Debug(msg string, args ...interface{})
- func (c *Entry) Error(msg string, args ...interface{})
- func (c *Entry) Fatal(msg string, args ...interface{})
- func (c *Entry) Info(msg string, args ...interface{})
- func (c *Entry) Log(keyvals ...interface{}) error
- func (c *Entry) Output(calldepth int, s string) error
- func (c *Entry) Panic(msg string, args ...interface{})
- func (c *Entry) Print(v ...interface{})
- func (c *Entry) Printf(format string, v ...interface{})
- func (c *Entry) Println(v ...interface{})
- func (c *Entry) Warn(msg string, args ...interface{})
- func (c *Entry) Warning(msg string, args ...interface{})
- func (c *Entry) WithAny(key string, val interface{}) Chain
- func (c *Entry) WithBinary(key string, val []byte) Chain
- func (c *Entry) WithBool(key string, val bool) Chain
- func (c *Entry) WithByteString(key string, val []byte) Chain
- func (c *Entry) WithComplex128(key string, val complex128) Chain
- func (c *Entry) WithComplex64(key string, val complex64) Chain
- func (c *Entry) WithDuration(key string, val time.Duration) Chain
- func (c *Entry) WithError(val error) Chain
- func (c *Entry) WithField(key string, value interface{}) Chain
- func (c *Entry) WithFields(fields Fields) Chain
- func (c *Entry) WithFloat32(key string, val float32) Chain
- func (c *Entry) WithFloat64(key string, val float64) Chain
- func (c *Entry) WithInt(key string, val int) Chain
- func (c *Entry) WithInt16(key string, val int16) Chain
- func (c *Entry) WithInt32(key string, val int32) Chain
- func (c *Entry) WithInt64(key string, val int64) Chain
- func (c *Entry) WithInt8(key string, val int8) Chain
- func (c *Entry) WithNamedError(key string, err error) Chain
- func (c *Entry) WithNamespace(key string) Chain
- func (c *Entry) WithReflect(key string, val interface{}) Chain
- func (c *Entry) WithStack(key string) Chain
- func (c *Entry) WithString(key string, val string) Chain
- func (c *Entry) WithStringer(key string, val fmt.Stringer) Chain
- func (c *Entry) WithTime(key string, val time.Time) Chain
- func (c *Entry) WithUint(key string, val uint) Chain
- func (c *Entry) WithUint16(key string, val uint16) Chain
- func (c *Entry) WithUint32(key string, val uint32) Chain
- func (c *Entry) WithUint64(key string, val uint64) Chain
- func (c *Entry) WithUint8(key string, val uint8) Chain
- func (c *Entry) WithUintptr(key string, val uintptr) Chain
- type Fields
- type GoogleSeverity
- type Log
- type LogConfig
- type WrappedLogger
- func (w *WrappedLogger) Chain() Chain
- func (w *WrappedLogger) Output(calldepth int, s string) error
- func (w *WrappedLogger) Print(v ...interface{})
- func (w *WrappedLogger) Printf(format string, v ...interface{})
- func (w *WrappedLogger) Println(v ...interface{})
- func (w *WrappedLogger) With(v ...interface{}) *WrappedLogger
Constants ¶
const EnvPrefix = "LOG"
EnvPrefix environment prefix for log config
Variables ¶
This section is empty.
Functions ¶
func Error ¶
func Error(message string, args ...interface{})
Error logs a message with some additional context
func Errorw ¶
func Errorw(message string, keyValues ...interface{})
Errorw logs a message with some additional context
func Fatal ¶
func Fatal(message string, args ...interface{})
Fatal logs a message to stderr and then calls an os.Exit
func Fatalw ¶
func Fatalw(message string, keyValues ...interface{})
Fatalw logs a message to stderr and then calls an os.Exit
func GoogleLevelEncoder ¶ added in v1.0.2
func GoogleLevelEncoder(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
func Info ¶
func Info(message string, args ...interface{})
Info logs a message with some additional context
func Infow ¶
func Infow(message string, keyValues ...interface{})
Infow logs a message with some additional context
func Panic ¶
func Panic(message string, args ...interface{})
Panic logs a message with some additional context, then panics
func Panicw ¶
func Panicw(message string, keyValues ...interface{})
Panicw logs a message with some additional context, then panics
func SetFormatter ¶
func SetFormatter(encoding string, encoderConfig zapcore.EncoderConfig)
SetFormatter set formatter
func Warn ¶
func Warn(message string, args ...interface{})
Warn logs a message with some additional context
func Warning ¶
func Warning(message string, args ...interface{})
Warning logs a message with some additional context
Types ¶
type Chain ¶
type Chain interface { Copy() Chain Debug(msg string, args ...interface{}) Info(msg string, args ...interface{}) Warn(msg string, args ...interface{}) Warning(msg string, args ...interface{}) Error(msg string, args ...interface{}) Fatal(msg string, args ...interface{}) Panic(msg string, args ...interface{}) WithBinary(key string, val []byte) Chain WithBool(key string, val bool) Chain WithByteString(key string, val []byte) Chain WithComplex128(key string, val complex128) Chain WithComplex64(key string, val complex64) Chain WithFloat64(key string, val float64) Chain WithFloat32(key string, val float32) Chain WithInt(key string, val int) Chain WithInt64(key string, val int64) Chain WithInt32(key string, val int32) Chain WithInt16(key string, val int16) Chain WithInt8(key string, val int8) Chain WithString(key string, val string) Chain WithError(val error) Chain WithNamedError(key string, err error) Chain WithUint(key string, val uint) Chain WithUint64(key string, val uint64) Chain WithUint32(key string, val uint32) Chain WithUint16(key string, val uint16) Chain WithUint8(key string, val uint8) Chain WithUintptr(key string, val uintptr) Chain WithReflect(key string, val interface{}) Chain WithNamespace(key string) Chain WithStringer(key string, val fmt.Stringer) Chain WithTime(key string, val time.Time) Chain WithStack(key string) Chain WithDuration(key string, val time.Duration) Chain WithAny(key string, val interface{}) Chain WithField(key string, value interface{}) Chain WithFields(fields Fields) Chain Print(v ...interface{}) Printf(format string, v ...interface{}) Println(v ...interface{}) Log(keyvals ...interface{}) error Output(calldepth int, s string) error }
Chain context provide functionality for log with predefined values
type Entry ¶
Entry contains values of given chain
func (*Entry) Println ¶
func (c *Entry) Println(v ...interface{})
Println logs a message at PanicLevel
func (*Entry) WithAny ¶
WithAny takes a key and an arbitrary value and chooses the best way to represent them as a field
func (*Entry) WithBinary ¶
WithBinary add a field that carries an opaque binary blob.
func (*Entry) WithByteString ¶
WithByteString add a field that carries UTF-8 encoded text as a []byte.
func (*Entry) WithComplex128 ¶
func (c *Entry) WithComplex128(key string, val complex128) Chain
WithComplex128 add a field that carries a complex number.
func (*Entry) WithComplex64 ¶
WithComplex64 add a field that carries a complex number
func (*Entry) WithDuration ¶
WithDuration add a field with the given key and value.
func (*Entry) WithFields ¶
WithFields return logger with given fields
func (*Entry) WithFloat32 ¶
WithFloat32 add a field that carries a float32
func (*Entry) WithFloat64 ¶
WithFloat64 add a field that carries a float64
func (*Entry) WithNamedError ¶
WithNamedError add a field with the given key and value.
func (*Entry) WithNamespace ¶
WithNamespace creates a named, isolated scope within the logger's context
func (*Entry) WithReflect ¶
WithReflect constructs a field with the given key and value.
func (*Entry) WithString ¶
WithString add a field with the given key and value.
func (*Entry) WithStringer ¶
WithStringer add a field with the given key and value.
func (*Entry) WithUint16 ¶
WithUint16 add a field with the given key and value.
func (*Entry) WithUint32 ¶
WithUint32 add a field with the given key and value.
func (*Entry) WithUint64 ¶
WithUint64 add a field with the given key and value.
type GoogleSeverity ¶ added in v1.0.2
type GoogleSeverity int
const ( GoogleSeverityDefault GoogleSeverity = 0 GoogleSeverityDebug GoogleSeverity = 100 GoogleSeverityInfo GoogleSeverity = 200 GoogleSeverityNotice GoogleSeverity = 300 GoogleSeverityWarning GoogleSeverity = 400 GoogleSeverityError GoogleSeverity = 500 GoogleSeverityCritical GoogleSeverity = 600 GoogleSeverityAlert GoogleSeverity = 700 GoogleSeverityEmergency GoogleSeverity = 800 )
func LevelToGoogleSeverity ¶ added in v1.0.2
func LevelToGoogleSeverity(level zapcore.Level) GoogleSeverity
func (GoogleSeverity) String ¶ added in v1.0.2
func (l GoogleSeverity) String() string
type Log ¶
type Log interface { Debugw(msg string, keyValues ...interface{}) Infow(msg string, keyValues ...interface{}) Warnw(msg string, keyValues ...interface{}) Errorw(msg string, keyValues ...interface{}) Panicw(msg string, keyValues ...interface{}) Fatalw(msg string, keyValues ...interface{}) Chain() Chain }
Log describe log wrapper interface
type LogConfig ¶
type LogConfig struct { Name string `default:"" split_words:"true"` Level int8 `default:"0" split_words:"true"` DisableCaller bool `default:"false" split_words:"true"` DisableStacktrace bool `default:"false" split_words:"true"` }
LogConfig contains name and level for log
func GetLogConfigFromEnv ¶
GetLogConfigFromEnv return log configs bases on environment variables
type WrappedLogger ¶
type WrappedLogger struct {
*zap.SugaredLogger
}
WrappedLogger is a logger that is wrapped with a config file It takes a config to determine which level its running at
func GetDefaultWrappedLogger ¶
func GetDefaultWrappedLogger(cfg *LogConfig, localCfg zap.Config) *WrappedLogger
GetDefaultWrappedLogger return default wrapper
func NewWrappedLogger ¶
func NewWrappedLogger(name string, config zap.Config, args ...interface{}) (*WrappedLogger, error)
NewWrappedLogger creates a new logger which wraps the given config
func (*WrappedLogger) Chain ¶
func (w *WrappedLogger) Chain() Chain
Chain return new chain with local context
func (*WrappedLogger) Output ¶
func (w *WrappedLogger) Output(calldepth int, s string) error
Output add support nsq output
func (*WrappedLogger) Print ¶
func (w *WrappedLogger) Print(v ...interface{})
Print logs a message at Info level
func (*WrappedLogger) Printf ¶
func (w *WrappedLogger) Printf(format string, v ...interface{})
Printf logs a message at Info level
func (*WrappedLogger) Println ¶
func (w *WrappedLogger) Println(v ...interface{})
Println logs a message at Info level
func (*WrappedLogger) With ¶
func (w *WrappedLogger) With(v ...interface{}) *WrappedLogger
With return new wrapped logger with default fields