Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(opts ...func(*zerolog.ConsoleWriter)) zerolog.Logger
New creates a new zerolog console logger, by default it uses RFC3339 as the time format.
Example ¶
package main import ( "github.com/revett/common/log" zerolog "github.com/rs/zerolog/log" ) func main() { zerolog.Logger = log.New( log.WithTimeFormat(""), log.WithNoColor(), ) zerolog.Info().Msg("example") }
Output: INF example
Types ¶
type NewFuncOption ¶
type NewFuncOption func(*zerolog.ConsoleWriter)
NewFuncOption is a functional option for the New function.
func WithNoColor ¶
func WithNoColor() NewFuncOption
WithNoColor is a functional option for the New function that disables colorized output for the logger.
func WithPrefix ¶
func WithPrefix(p string) NewFuncOption
WithPrefix is a functional option for the New function that allows a prefix to be added to the logger.
Example ¶
package main import ( "github.com/revett/common/log" zerolog "github.com/rs/zerolog/log" ) func main() { zerolog.Logger = log.New( log.WithTimeFormat(""), log.WithNoColor(), log.WithPrefix("service"), ) zerolog.Info().Msg("example") }
Output: INF service example
func WithTimeFormat ¶
func WithTimeFormat(t string) NewFuncOption
WithTimeFormat is a functional option for the New function that allows a custom time format to be set for the logger.
Click to show internal directories.
Click to hide internal directories.