zerolog

package module
v2.0.0-...-03508dc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

Zerolog

Zerolog logger implementation for go-micro meta logger.

Usage

func ExampleWithOut() {
  logger.DefaultLogger = zerolog.NewLogger(logger.WithOutput(os.Stdout), logger.WithLevel(logger.DebugLevel))

  logger.Infof(logger.InfoLevel, "testing: %s", "Infof")

  // Output:
  // {"level":"info","message":"testing: Infof"}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(opts ...logger.Option) logger.Logger

NewLogger builds a new logger based on options

func ReportCaller

func ReportCaller() logger.Option

func UseAsDefault

func UseAsDefault() logger.Option

func WithDevelopmentMode

func WithDevelopmentMode() logger.Option

func WithExitFunc

func WithExitFunc(exit func(int)) logger.Option

func WithHooks

func WithHooks(hooks []zerolog.Hook) logger.Option

func WithProductionMode

func WithProductionMode() logger.Option

func WithTimeFormat

func WithTimeFormat(timeFormat string) logger.Option

func ZerologToLoggerLevel

func ZerologToLoggerLevel(level zerolog.Level) logger.Level

Types

type Mode

type Mode uint8
const (
	Production Mode = iota
	Development
)

type Options

type Options struct {
	logger.Options

	// Flag for whether to log caller info (off by default)
	ReportCaller bool
	// Use this logger as system wide default logger  (off by default)
	UseAsDefault bool
	// zerolog hooks
	Hooks []zerolog.Hook
	// TimeFormat is one of time.RFC3339, time.RFC3339Nano, time.*
	TimeFormat string
	// Runtime mode. (Production by default)
	Mode Mode
	// Exit Function to call when FatalLevel log
	ExitFunc func(int)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL