fabric: github.com/hyperledger/fabric/common/flogging/fabenc Index | Files

package fabenc

import "github.com/hyperledger/fabric/common/flogging/fabenc"

Index

Package Files

color.go encoder.go formatter.go

func ResetColor Uses

func ResetColor() string

func SetSequence Uses

func SetSequence(s uint64)

SetSequence explicitly sets the global sequence number.

type Color Uses

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

func (Color) Bold Uses

func (c Color) Bold() string

func (Color) Normal Uses

func (c Color) Normal() string

type ColorFormatter Uses

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 Uses

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 Uses

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

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

type FormatEncoder Uses

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 Uses

func NewFormatEncoder(formatters ...Formatter) *FormatEncoder

func (*FormatEncoder) Clone Uses

func (f *FormatEncoder) Clone() zapcore.Encoder

Clone creates a new instance of this encoder with the same configuration.

func (*FormatEncoder) EncodeEntry Uses

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 Uses

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 Uses

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 Uses

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 Uses

type LevelFormatter struct{ FormatVerb string }

LevelFormatter formats a log level.

func (LevelFormatter) Format Uses

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

Format writes the logging level to the provided writer.

type MessageFormatter Uses

type MessageFormatter struct{ FormatVerb string }

MessageFormatter formats a log message.

func (MessageFormatter) Format Uses

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 Uses

type ModuleFormatter struct{ FormatVerb string }

ModuleFormatter formats the zap logger name.

func (ModuleFormatter) Format Uses

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 Uses

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 Uses

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 Uses

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 Uses

func (m *MultiFormatter) SetFormatters(formatters []Formatter)

SetFormatters replaces the delegate formatters.

type SequenceFormatter Uses

type SequenceFormatter struct{ FormatVerb string }

SequenceFormatter formats a global sequence number.

func (SequenceFormatter) Format Uses

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 Uses

type ShortFuncFormatter struct{ FormatVerb string }

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

func (ShortFuncFormatter) Format Uses

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 Uses

type StringFormatter struct{ Value string }

A StringFormatter formats a fixed string.

func (StringFormatter) Format Uses

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 Uses

type TimeFormatter struct{ Layout string }

TimeFormatter formats the time from the zap log entry.

func (TimeFormatter) Format Uses

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

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

Package fabenc imports 11 packages (graph) and is imported by 2 packages. Updated 2019-03-05. Refresh now. Tools for package owners.