fabenc

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

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 Color

type Color uint8
const (
	ColorBlack Color = iota + 30
	ColorRed
	ColorGreen
	ColorYellow
	ColorBlue
	ColorMagenta
	ColorCyan
	ColorWhite
)
const ColorNone Color = 0

func (Color) Bold

func (c Color) Bold() string

func (Color) Normal

func (c Color) Normal() string

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) Format

func (c ColorFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)

Format writes the SGR color code to the provided writer.

func (ColorFormatter) LevelColor

func (c ColorFormatter) LevelColor(l zapcore.Level) Color

LevelColor returns the Color associated with a specific zap logging level.

type FormatEncoder

type FormatEncoder struct {
	zapcore.Encoder
	// contains filtered or unexported fields
}

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

type Formatter interface {
	Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)
}

A Formatter is used to format and write data from a zap log entry.

func NewFormatter

func NewFormatter(verb, format string) (Formatter, error)

NewFormatter creates the formatter for the provided verb. When a format is not provided, the default format for the verb is used.

func ParseFormat

func ParseFormat(spec string) ([]Formatter, error)

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.

func (LevelFormatter) Format

func (l LevelFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)

Format writes the logging level to the provided writer.

type MessageFormatter

type MessageFormatter struct{ FormatVerb string }

MessageFormatter formats a log message.

func (MessageFormatter) Format

func (m MessageFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)

Format writes the log entry message to the provided writer.

type ModuleFormatter

type ModuleFormatter struct{ FormatVerb string }

ModuleFormatter formats the zap logger name.

func (ModuleFormatter) Format

func (m ModuleFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)

Format writes the zap logger name to the specified writer.

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

func (m *MultiFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)

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.

func (SequenceFormatter) Format

func (s SequenceFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)

SequenceFormatter increments a global sequence number and writes it to the provided writer.

type ShortFuncFormatter

type ShortFuncFormatter struct{ FormatVerb string }

ShortFuncFormatter formats the name of the function creating the log record.

func (ShortFuncFormatter) Format

func (s ShortFuncFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)

Format writes the calling function name to the provided writer. The name is obtained from the runtime and the package and line numbers are discarded.

type StringFormatter

type StringFormatter struct{ Value string }

A StringFormatter formats a fixed string.

func (StringFormatter) Format

func (s StringFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)

Format writes the formatter's fixed string to provided writer.

type TimeFormatter

type TimeFormatter struct{ Layout string }

TimeFormatter formats the time from the zap log entry.

func (TimeFormatter) Format

func (t TimeFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)

Format writes the log record time stamp to the provided writer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL