...

Package fabenc

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

Overview ▾

Index ▾

func ResetColor() string
func SetSequence(s uint64)
type Color
    func (c Color) Bold() string
    func (c Color) Normal() string
type ColorFormatter
    func (c ColorFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)
    func (c ColorFormatter) LevelColor(l zapcore.Level) Color
type FormatEncoder
    func NewFormatEncoder(formatters ...Formatter) *FormatEncoder
    func (f *FormatEncoder) Clone() zapcore.Encoder
    func (f *FormatEncoder) EncodeEntry(entry zapcore.Entry, fields []zapcore.Field) (*buffer.Buffer, error)
type Formatter
    func NewFormatter(verb, format string) (Formatter, error)
    func ParseFormat(spec string) ([]Formatter, error)
type LevelFormatter
    func (l LevelFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)
type MessageFormatter
    func (m MessageFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)
type ModuleFormatter
    func (m ModuleFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)
type MultiFormatter
    func NewMultiFormatter(formatters ...Formatter) *MultiFormatter
    func (m *MultiFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)
    func (m *MultiFormatter) SetFormatters(formatters []Formatter)
type SequenceFormatter
    func (s SequenceFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)
type ShortFuncFormatter
    func (s ShortFuncFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)
type StringFormatter
    func (s StringFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)
type TimeFormatter
    func (t TimeFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field)

Package files

color.go encoder.go formatter.go

func ResetColor

func ResetColor() string

func SetSequence

func SetSequence(s uint64)

SetSequence explicitly sets the global sequence number.

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

A ColorFormatter formats an SGR color code.

type ColorFormatter struct {
    Bold  bool // set the bold attribute
    Reset bool // reset colors and attributes
}

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

A FormatEncoder is a zapcore.Encoder that formats log records according to a go-logging based format specifier.

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

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.

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

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

LevelFormatter formats a log level.

type LevelFormatter struct{ FormatVerb string }

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

MessageFormatter formats a log message.

type MessageFormatter struct{ FormatVerb string }

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

ModuleFormatter formats the zap logger name.

type ModuleFormatter struct{ FormatVerb string }

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

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.

type MultiFormatter struct {
    // contains filtered or unexported fields
}

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

SequenceFormatter formats a global sequence number.

type SequenceFormatter struct{ FormatVerb string }

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

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

type ShortFuncFormatter struct{ FormatVerb string }

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

A StringFormatter formats a fixed string.

type StringFormatter struct{ Value 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

TimeFormatter formats the time from the zap log entry.

type TimeFormatter struct{ Layout string }

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.