Documentation
¶
Overview ¶
Package encoder provides the encoder to encode the log message.
Index ¶
- Variables
- type BoolEncoder
- type DurationEncoder
- type Float64Encoder
- type Int64Encoder
- type IntEncoder
- type JSONEncoder
- func (enc *JSONEncoder) Encode(buf []byte, key string, value interface{}) []byte
- func (enc *JSONEncoder) EncodeBool(dst []byte, key string, value bool) []byte
- func (enc *JSONEncoder) EncodeDuration(dst []byte, key string, value time.Duration) []byte
- func (enc *JSONEncoder) EncodeFloat64(dst []byte, key string, value float64) []byte
- func (enc *JSONEncoder) EncodeInt(dst []byte, key string, value int) []byte
- func (enc *JSONEncoder) EncodeInt64(dst []byte, key string, value int64) []byte
- func (enc *JSONEncoder) EncodeString(dst []byte, key string, value string) []byte
- func (enc *JSONEncoder) EncodeStringSlice(dst []byte, key string, value []string) []byte
- func (enc *JSONEncoder) EncodeTime(dst []byte, key string, value time.Time) []byte
- func (enc *JSONEncoder) EncodeUint(dst []byte, key string, value uint) []byte
- func (enc *JSONEncoder) EncodeUint64(dst []byte, key string, value uint64) []byte
- func (enc *JSONEncoder) End(buf []byte, msg string) []byte
- func (enc *JSONEncoder) Start(buf []byte, name, level string) []byte
- type StringEncoder
- type StringSliceEncoder
- type TimeEncoder
- type Uint64Encoder
- type UintEncoder
Constants ¶
This section is empty.
Variables ¶
var Now = time.Now
Now is used to get the current time.
Functions ¶
This section is empty.
Types ¶
type BoolEncoder ¶
BoolEncoder is used to encode the value typed bool.
type DurationEncoder ¶
type DurationEncoder interface {
EncodeDuration(dst []byte, key string, value time.Duration) []byte
}
DurationEncoder is used to encode the value typed time.Duration.
type Float64Encoder ¶
Float64Encoder is used to encode the key and the value typed float64.
type Int64Encoder ¶
Int64Encoder is used to encode the key and the value typed int64.
type IntEncoder ¶
IntEncoder is used to encode the key and the value typed int.
type JSONEncoder ¶
type JSONEncoder struct { kvjson.JSON // If true, append a newline when emit the log record. // // Default: true Newline bool // TimeKey is the key name of the time when to emit the log record if not empty. // // Default: "t" TimeKey string // LevelKey is the key name of the level if not empty. // // Default: "lvl" LevelKey string // LoggerKey is the key name of the logger name. // // Default: "logger" LoggerKey string // MsgKey is the key name of the message. // // Default: "msg" MsgKey string }
JSONEncoder is a log encoder to encode the log record as JSON.
func NewJSONEncoder ¶
func NewJSONEncoder() *JSONEncoder
NewJSONEncoder returns a new JSONEncoder.
If formatLevel is nil, disable to format the level.
func (*JSONEncoder) Encode ¶
func (enc *JSONEncoder) Encode(buf []byte, key string, value interface{}) []byte
Encode implements the interface Encoder by using kvjson.JSON.EncodeKV.
func (*JSONEncoder) EncodeBool ¶
func (enc *JSONEncoder) EncodeBool(dst []byte, key string, value bool) []byte
EncodeBool implements the interface BoolEncoder.
func (*JSONEncoder) EncodeDuration ¶
EncodeDuration implements the interface DurationEncoder.
func (*JSONEncoder) EncodeFloat64 ¶
func (enc *JSONEncoder) EncodeFloat64(dst []byte, key string, value float64) []byte
EncodeFloat64 implements the interface Float64Encoder.
func (*JSONEncoder) EncodeInt ¶
func (enc *JSONEncoder) EncodeInt(dst []byte, key string, value int) []byte
EncodeInt implements the interface IntEncoder.
func (*JSONEncoder) EncodeInt64 ¶
func (enc *JSONEncoder) EncodeInt64(dst []byte, key string, value int64) []byte
EncodeInt64 implements the interface Int64Encoder.
func (*JSONEncoder) EncodeString ¶
func (enc *JSONEncoder) EncodeString(dst []byte, key string, value string) []byte
EncodeString implements the interface StringEncoder.
func (*JSONEncoder) EncodeStringSlice ¶ added in v0.12.0
func (enc *JSONEncoder) EncodeStringSlice(dst []byte, key string, value []string) []byte
EncodeStringSlice implements the interface StringSliceEncoder.
func (*JSONEncoder) EncodeTime ¶
EncodeTime implements the interface TimeEncoder.
func (*JSONEncoder) EncodeUint ¶
func (enc *JSONEncoder) EncodeUint(dst []byte, key string, value uint) []byte
EncodeUint implements the interface UintEncoder.
func (*JSONEncoder) EncodeUint64 ¶
func (enc *JSONEncoder) EncodeUint64(dst []byte, key string, value uint64) []byte
EncodeUint64 implements the interface Uint64Encoder.
type StringEncoder ¶
StringEncoder is used to encode the value typed string.
type StringSliceEncoder ¶ added in v0.12.0
type StringSliceEncoder interface {
EncodeStringSlice(dst []byte, key string, value []string) []byte
}
StringSliceEncoder is used to encode the value typed []string.
type TimeEncoder ¶
TimeEncoder is used to encode the value typed time.Time.
type Uint64Encoder ¶
Uint64Encoder is used to encode the key and the value typed uint64.