Documentation ¶
Index ¶
- Variables
- type Entry
- func (e *Entry) Buffer() *byteutil.Buffer
- func (e *Entry) Bytes() []byte
- func (e *Entry) Caller(calldepth int)
- func (e *Entry) Context() context.Context
- func (e *Entry) Field(key string, value interface{})
- func (e *Entry) Fields(fields ...kv.Field)
- func (e *Entry) Level() level.LEVEL
- func (e *Entry) Msg(a ...interface{})
- func (e *Entry) Msgf(s string, a ...interface{})
- func (e *Entry) Reset()
- func (e *Entry) SetFormat(fmt Formatter)
- func (e *Entry) String() string
- func (e *Entry) Timestamp()
- func (e *Entry) WithContext(ctx context.Context)
- func (e *Entry) WithLevel(lvl level.LEVEL)
- type FieldFormatter
- func (f *FieldFormatter) Caller(buf *byteutil.Buffer, calldepth int)
- func (f *FieldFormatter) Fields(buf *byteutil.Buffer, fields []kv.Field)
- func (f *FieldFormatter) Level(buf *byteutil.Buffer, lvl level.LEVEL)
- func (f *FieldFormatter) Msg(buf *byteutil.Buffer, a ...interface{})
- func (f *FieldFormatter) Msgf(buf *byteutil.Buffer, s string, a ...interface{})
- func (f *FieldFormatter) Timestamp(buf *byteutil.Buffer)
- type Formatter
- type TextFormatter
- func (f *TextFormatter) Caller(buf *byteutil.Buffer, calldepth int)
- func (f *TextFormatter) Fields(buf *byteutil.Buffer, fields []kv.Field)
- func (f *TextFormatter) Level(buf *byteutil.Buffer, lvl level.LEVEL)
- func (f *TextFormatter) Msg(buf *byteutil.Buffer, a ...interface{})
- func (f *TextFormatter) Msgf(buf *byteutil.Buffer, s string, a ...interface{})
- func (f *TextFormatter) Timestamp(buf *byteutil.Buffer)
Constants ¶
This section is empty.
Variables ¶
var DefaultFormatter = NewTextFormatter(nil)
DefaultFormatter is the global default formatter, useful when in case of nil Formatter, or simply wanting defaults.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry represents a single entry in a log. It provides methods for writing formatted data to a byte buffer before making a singular write to an io.Writer.
func (*Entry) Buffer ¶
func (e *Entry) Buffer() *byteutil.Buffer
Buffer returns the underlying format buffer.
func (*Entry) Fields ¶
func (e *Entry) Fields(fields ...kv.Field)
Fields will write formatted key-value fields to the entry.
func (*Entry) Msg ¶
func (e *Entry) Msg(a ...interface{})
Msg will write given arguments as message to the entry.
func (*Entry) Reset ¶
func (e *Entry) Reset()
Reset will reset the entry's current context, level and buffer.
func (*Entry) String ¶
String returns the currently accumulated entry buffer bytes as string, please note this points to the underlying byte slice.
func (*Entry) Timestamp ¶
func (e *Entry) Timestamp()
Timestamp will write formatted timestamp to the entry.
func (*Entry) WithContext ¶
WithContext updates the entry to use the provided context.
type FieldFormatter ¶
type FieldFormatter struct {
// contains filtered or unexported fields
}
FieldFormatter is a level.Levels typedef to implement the Formatter interface, in a manner that provides logging with timestamp, caller info and level prefixing log entries in key-value formatting.
func (*FieldFormatter) Caller ¶
func (f *FieldFormatter) Caller(buf *byteutil.Buffer, calldepth int)
func (*FieldFormatter) Fields ¶
func (f *FieldFormatter) Fields(buf *byteutil.Buffer, fields []kv.Field)
func (*FieldFormatter) Level ¶
func (f *FieldFormatter) Level(buf *byteutil.Buffer, lvl level.LEVEL)
func (*FieldFormatter) Msg ¶
func (f *FieldFormatter) Msg(buf *byteutil.Buffer, a ...interface{})
func (*FieldFormatter) Msgf ¶
func (f *FieldFormatter) Msgf(buf *byteutil.Buffer, s string, a ...interface{})
func (*FieldFormatter) Timestamp ¶
func (f *FieldFormatter) Timestamp(buf *byteutil.Buffer)
type Formatter ¶
type Formatter interface { // Level will append formatted level string to buffer. Level(buf *byteutil.Buffer, lvl level.LEVEL) // Timestamp will append formatted timestamp string to buffer. Timestamp(buf *byteutil.Buffer) // Caller will append formatted caller information to buffer. Caller(buf *byteutil.Buffer, calldepth int) // Fields will append formatted key-value fields to buffer. Fields(buf *byteutil.Buffer, fields []kv.Field) // Msg will append formatted msg arguments to buffer. Msg(buf *byteutil.Buffer, args ...interface{}) // Msgf will append formatted msg format string with arguments to buffer. Msgf(buf *byteutil.Buffer, format string, args ...interface{}) }
Formatter provides formatting for various standard data types being written to an entry's format buffer.
func NewFieldFormatter ¶
NewFieldFormatter returns a prepared FieldFormatter instance, using provided level.Levels for printing of level strings, else uses defaults.
func NewTextFormatter ¶
NewTextFormatter returns a prepared TextFormatter instance, using provided level.Levels for printing of level strings, else uses defaults.
type TextFormatter ¶
type TextFormatter struct {
// contains filtered or unexported fields
}
TextFormatter is a Levels typedef to implement the Formatter interface, in a manner that provides logging with timestamp, caller info and level prefixing log entries in plain printed text.
func (*TextFormatter) Caller ¶
func (f *TextFormatter) Caller(buf *byteutil.Buffer, calldepth int)
func (*TextFormatter) Fields ¶
func (f *TextFormatter) Fields(buf *byteutil.Buffer, fields []kv.Field)
func (*TextFormatter) Level ¶
func (f *TextFormatter) Level(buf *byteutil.Buffer, lvl level.LEVEL)
func (*TextFormatter) Msg ¶
func (f *TextFormatter) Msg(buf *byteutil.Buffer, a ...interface{})
func (*TextFormatter) Msgf ¶
func (f *TextFormatter) Msgf(buf *byteutil.Buffer, s string, a ...interface{})
func (*TextFormatter) Timestamp ¶
func (f *TextFormatter) Timestamp(buf *byteutil.Buffer)