zerolog

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: Apache-2.0 Imports: 9 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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