Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewZapLogger ¶
NewZapLogger returns a new zap.Logger with the given config.
Types ¶
type Config ¶
type Config struct {
Level zapcore.Level
CallerKey string
LevelKey string
MessageKey string
NameKey string
TimeKey string
StacktraceKey string
Encoder EncoderType
TimeEncoder TimeEncoderType
LevelEncoder LevelEncoderType
EnableStacktrace bool
EnableCaller bool
SampleInitial int
SampleThereafter int
Metrics *Metrics
WriteSyncer zapcore.WriteSyncer
}
Config specifies the configuration of a Logger.
func (*Config) RegisterCommonFlags ¶
RegisterCommonFlags registers basic fields of the Config as flags in the FlagSet. If fs is nil, flag.CommandLine is used.
type EncoderType ¶
type EncoderType int
An EncoderType specifies which Encoder to use.
const ( // JSONType creates a fast, low-allocation JSON encoder. JSONType EncoderType = iota // ConsoleType creates an encoder whose output is designed for human // consumption, rather than machine consumption. ConsoleType )
func (*EncoderType) Get ¶
func (t *EncoderType) Get() interface{}
Get implements the flag.Getter interface.
func (*EncoderType) Set ¶
func (t *EncoderType) Set(s string) error
Set implements the flag.Value interface.
func (*EncoderType) String ¶
func (t *EncoderType) String() string
String implements the flag.Value interface.
type LevelEncoderType ¶
type LevelEncoderType int
A LevelEncoderType specifies which LevelEncoder to use.
const ( // UppercaseType serializes a Level to an all-caps string. For example, // InfoLevel is serialized to "INFO". UppercaseType LevelEncoderType = iota // LowercaseType serializes a Level to a lowercase string. For example, // InfoLevel is serialized to "info". LowercaseType // ColorType serializes a Level to an all-caps string and adds color. // For example, InfoLevel is serialized to "INFO" and colored blue. ColorType )
func (*LevelEncoderType) Get ¶
func (t *LevelEncoderType) Get() interface{}
Get implements the flag.Getter interface.
func (*LevelEncoderType) Set ¶
func (t *LevelEncoderType) Set(s string) error
Set implements the flag.Value interface.
func (*LevelEncoderType) String ¶
func (t *LevelEncoderType) String() string
String implements the flag.Value interface.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics are a prometheus.Collector for log metrics.
func (*Metrics) Collect ¶
func (m *Metrics) Collect(ch chan<- prometheus.Metric)
Collect implements the prometheus.Collector interface.
func (*Metrics) Describe ¶
func (m *Metrics) Describe(ch chan<- *prometheus.Desc)
Describe implements the prometheus.Collector interface.
type TimeEncoderType ¶
type TimeEncoderType int
A TimeEncoderType specifies which TimeEncoder to use.
const ( // ISO8601Type serializes a time.Time to an ISO8601-formatted string with // millisecond precision. ISO8601Type TimeEncoderType = iota // MillisecondsType serializes a time.Time to a floating-point number of // milliseconds since the Unix epoch. MillisecondsType // NanosecondsType serializes a time.Time to an integer number of nanoseconds // since the Unix epoch. NanosecondsType // SecondsType serializes a time.Time to a floating-point number of seconds // since the Unix epoch. SecondsType )
func (*TimeEncoderType) Get ¶
func (t *TimeEncoderType) Get() interface{}
Get implements the flag.Getter interface.
func (*TimeEncoderType) Set ¶
func (t *TimeEncoderType) Set(s string) error
Set implements the flag.Value interface.
func (*TimeEncoderType) String ¶
func (t *TimeEncoderType) String() string
String implements the flag.Value interface.