logging

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAdapter added in v0.18.0

func NewAdapter(l zerolog.Logger) *goLog.Logger

func NewRootLogger

func NewRootLogger(options LoggerOutputOptions) (zerolog.Logger, func())

NewRootLogger creates a new zerolog logger with default settings.

func RegisterContextProvider

func RegisterContextProvider(p ContextProvider)

RegisterContextProvider records a given context provider. This method is supposed to be called in an `init` method.

func With

With creates a zerolog Context that contains all information available in the given context.

Types

type ContextProvider

type ContextProvider func(ctx context.Context, c zerolog.Context) zerolog.Context

type LoggerOutputOptions

type LoggerOutputOptions struct {
	Color      bool       // Produce colored logs
	TimeFormat TimeFormat // Instructs how to print time in logs
	Stderr     bool       // Write logs to stderr
	LogFile    string     // Path of file to write to
}

type Service

type Service interface {
	// MustGetLogger creates a logger with given name.
	MustGetLogger(name string) zerolog.Logger
	// MustSetLevel sets the log level for the component with given name to given level.
	MustSetLevel(name, level string)
	// RotateLogFiles re-opens log file writer.
	RotateLogFiles()
}

Service exposes the interfaces for a logger service that supports different loggers with different levels.

func NewService

func NewService(defaultLevel string, options LoggerOutputOptions) (Service, error)

NewService creates a new Service.

type TimeFormat

type TimeFormat int
const (
	TimeFormatLocal TimeFormat = 0
	TimeFormatUTC   TimeFormat = 1
)

Jump to

Keyboard shortcuts

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