Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResetColor ¶
func ResetColor() string
func SetSequence ¶
func SetSequence(s uint64)
SetSequence explicitly sets the global sequence number.
Types ¶
type ColorFormatter ¶
type ColorFormatter struct { Bold bool // set the bold attribute Reset bool // reset colors and attributes }
A ColorFormatter formats an SGR color code.
func (ColorFormatter) LevelColor ¶
func (c ColorFormatter) LevelColor(l zapcore.Level) Color
LevelColor returns the Color associated with a specific zap logging level.
type FormatEncoder ¶
A FormatEncoder is a zapcore.Encoder that formats log records according to a go-logging based format specifier.
func NewFormatEncoder ¶
func NewFormatEncoder(formatters ...Formatter) *FormatEncoder
func (*FormatEncoder) Clone ¶
func (f *FormatEncoder) Clone() zapcore.Encoder
Clone creates a new instance of this encoder with the same configuration.
func (*FormatEncoder) EncodeEntry ¶
func (f *FormatEncoder) EncodeEntry(entry zapcore.Entry, fields []zapcore.Field) (*buffer.Buffer, error)
EncodeEntry formats a zap log record. The structured fields are formatted by a zapcore.ConsoleEncoder and are appended as JSON to the end of the formatted entry. All entries are terminated by a newline.
type Formatter ¶
A Formatter is used to format and write data from a zap log entry.
func NewFormatter ¶
NewFormatter creates the formatter for the provided verb. When a format is not provided, the default format for the verb is used.
func ParseFormat ¶
ParseFormat parses a log format spec and returns a slice of formatters that should be iterated over to build a formatted log record.
The op-loggng specifiers supported by this formatter are:
- %{color} - level specific SGR color escape or SGR reset
- %{id} - a unique log sequence number
- %{level} - the log level of the entry
- %{message} - the log message
- %{module} - the zap logger name
- %{shortfunc} - the name of the function creating the log record
- %{time} - the time the log entry was created
Specifiers may include an optional format verb:
- color: reset|bold
- id: a fmt style numeric formatter without the leading %
- level: a fmt style string formatter without the leading %
- message: a fmt style string formatter without the leading %
- module: a fmt style string formatter without the leading %
type LevelFormatter ¶
type LevelFormatter struct{ FormatVerb string }
LevelFormatter formats a log level.
type MessageFormatter ¶
type MessageFormatter struct{ FormatVerb string }
MessageFormatter formats a log message.
type ModuleFormatter ¶
type ModuleFormatter struct{ FormatVerb string }
ModuleFormatter formats the zap logger name.
type MultiFormatter ¶
type MultiFormatter struct {
// contains filtered or unexported fields
}
A MultiFormatter presents multiple formatters as a single Formatter. It can be used to change the set of formatters associated with an encoder at runtime.
func NewMultiFormatter ¶
func NewMultiFormatter(formatters ...Formatter) *MultiFormatter
NewMultiFormatter creates a new MultiFormatter that delegates to the provided formatters. The formatters are used in the order they are presented.
func (*MultiFormatter) Format ¶
Format iterates over its delegates to format a log record to the provided buffer.
func (*MultiFormatter) SetFormatters ¶
func (m *MultiFormatter) SetFormatters(formatters []Formatter)
SetFormatters replaces the delegate formatters.
type SequenceFormatter ¶
type SequenceFormatter struct{ FormatVerb string }
SequenceFormatter formats a global sequence number.
type ShortFuncFormatter ¶
type ShortFuncFormatter struct{ FormatVerb string }
ShortFuncFormatter formats the name of the function creating the log record.
type StringFormatter ¶
type StringFormatter struct{ Value string }
A StringFormatter formats a fixed string.
type TimeFormatter ¶
type TimeFormatter struct{ Layout string }
TimeFormatter formats the time from the zap log entry.