Documentation ¶
Index ¶
- Variables
- func AbbrLevelEncoder(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
- func JustTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- func NewColorizedConsoleEncoder(cfg *zapcore.EncoderConfig, colorizer Colorizer) zapcore.Encoder
- func NewConsoleEncoder(cfg *zapcore.EncoderConfig) zapcore.Encoder
- func NewDevelopmentEncoderConfig() zapcore.EncoderConfig
- func NewEncoderConfig() zapcore.EncoderConfig
- func NewLTSVEncoder(cfg *zapcore.EncoderConfig) zapcore.Encoder
- type Colorizer
- type Colors
Constants ¶
This section is empty.
Variables ¶
var Bright = ansi.ColorCode("default+b")
Bright is the color used for the message
var DefaultColors = Colors{ Debug: ansi.ColorCode("cyan"), Info: ansi.ColorCode("green+h"), Warn: ansi.ColorCode("yellow+bh"), Error: ansi.ColorCode("red+bh"), }
DefaultColors is the default instance of Colors, used as the default colors if a nil Colorizer is passed to NewColorizedConsoleEncoder.
var Dim = ansi.ColorCode("240")
Dim is the color used for context keys, time, and caller information
Functions ¶
func AbbrLevelEncoder ¶
func AbbrLevelEncoder(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
AbbrLevelEncoder encodes logging levels to the strings in the log entries. Encodes levels as 3-char abbreviations in upper case.
encConfig := flume.EncoderConfig{} encConfig.EncodeTime = flume.AbbrLevelEncoder
func JustTimeEncoder ¶
func JustTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
JustTimeEncoder is a timestamp encoder function which encodes time as a simple time of day, without a date. Intended for development and testing. Not good in a production system, where you probably need to know the date.
encConfig := flume.EncoderConfig{} encConfig.EncodeTime = flume.JustTimeEncoder
func NewColorizedConsoleEncoder ¶
func NewColorizedConsoleEncoder(cfg *zapcore.EncoderConfig, colorizer Colorizer) zapcore.Encoder
NewColorizedConsoleEncoder creates a console encoder, like NewConsoleEncoder, but colors the text with ansi escape codes. `colorize` configures which colors to use for each level.
If `colorizer` is nil, it will default to DefaultColors.
`github.com/mgutz/ansi` is a convenient package for getting color codes, e.g.:
ansi.ColorCode("red")
func NewConsoleEncoder ¶
func NewConsoleEncoder(cfg *zapcore.EncoderConfig) zapcore.Encoder
NewConsoleEncoder creates an encoder whose output is designed for human - rather than machine - consumption. It serializes the core log entry data (message, level, timestamp, etc.) in a plain-text format. The context is encoded in LTSV.
Note that although the console encoder doesn't use the keys specified in the encoder configuration, it will omit any element whose key is set to the empty string.
func NewDevelopmentEncoderConfig ¶
func NewDevelopmentEncoderConfig() zapcore.EncoderConfig
NewDevelopmentEncoderConfig returns an EncoderConfig which is intended for local development.
func NewEncoderConfig ¶
func NewEncoderConfig() zapcore.EncoderConfig
NewEncoderConfig returns an EncoderConfig with default settings.
func NewLTSVEncoder ¶
func NewLTSVEncoder(cfg *zapcore.EncoderConfig) zapcore.Encoder
NewLTSVEncoder creates a fast, low-allocation LTSV encoder.