Documentation
¶
Overview ¶
Package log provides tools to setup the zerolog logger.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidLevel will be returned when the level given to the WithLevel // option is invalid. ErrInvalidLevel = errors.New("invalid level") // ErrInvalidOutput will be returned when the output writer given to WithOutput // is nil. ErrInvalidOutput = errors.New("invalid output") )
Functions ¶
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option provides for Logger configuration.
func WithLevelFieldName ¶
WithLevelFieldName allows the customization of the level name. It defaults to "level".
func WithMessageFieldName ¶
WithMessageFieldName allows the customization of the message name. It defaults to "message".
func WithOutput ¶
WithOutput allows the format to be configured. The default writer is os.Stdout.
func WithTimestampFieldName ¶
WithTimestampFieldName allows the customization of the timestamp name. It defaults to "time".
func WithoutTimestamp ¶
func WithoutTimestamp() Option
WithoutTimestamp disables the use of a timestamp for logs. Useful for unit tests.
type StringBuffer ¶
type StringBuffer struct {
// contains filtered or unexported fields
}
StringBuffer implements a simple buffer that can be used in tests. It implements the io.WriteCloser interface. Each write will append a string to the Buffer.
func SetupTestLogging ¶
func SetupTestLogging(t *testing.T) (context.Context, *StringBuffer)
SetupTestLogging creates a string buffer, a logger that writes to the string buffer and a context which contains the logger.
func (*StringBuffer) Close ¶
func (l *StringBuffer) Close() error
Close allows the string buffer to satisfy the io.WriteCloser interface.
func (*StringBuffer) Index ¶
func (l *StringBuffer) Index(i int) string
Index returns the string at the given index.
func (*StringBuffer) Len ¶
func (l *StringBuffer) Len() int
Len returns the length of the string buffer.