logger

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MPL-2.0 Imports: 5 Imported by: 13

Documentation

Index

Constants

View Source
const (
	// LogLevelDebug = -1
	LogLevelDebug int = -int(zap.DebugLevel)
	// LogLevelInfo = 0
	LogLevelInfo int = -int(zap.InfoLevel)
	// LogLevelWarn = 1
	LogLevelWarn int = -int(zap.WarnLevel)
	// LogLevelError = 2
	LogLevelError int = -int(zap.ErrorLevel)
)

Levels can be used with log.V() to temporarily reset the configured Level Levels are in order of decreasing verbosity and increasing importance

View Source
const (
	DefaultLogLevel = "info"
)

Variables

This section is empty.

Functions

func BuildConfig

func BuildConfig(opts ...LogOption) zap.Config

New builds a new Logger Config

func New

func New(level string, devMode bool) (logr.Logger, error)

New returns a new Logger instance

func NewFromConfig

func NewFromConfig(cfg zap.Config) (logr.Logger, error)

NewFromConfig creates a new logr Logger from a zap Config

Types

type LogOption

type LogOption func(*zap.Config)

LogOption is an option which can be applied to the Logger Config

func WithDevelopment

func WithDevelopment() LogOption

WithDevelopment sets some Development mode defaults

func WithDisableStackTrace

func WithDisableStackTrace() LogOption

WithDisableStackTrace disables the stack traces printed out with Error and Warn levels

func WithEncoding

func WithEncoding(e string) LogOption

WithEncoding sets the encoding for the logger (eg "console" or "json"

func WithHumanTimeCode

func WithHumanTimeCode() LogOption

WithHumanTimeCode can be used to set more human readable time on Production logs

func WithLogLevel

func WithLogLevel(l zapcore.Level) LogOption

WithLogLevel will set the log level on the Logger Config

func WithMode

func WithMode(devMode bool) LogOption

WithMode sets up some default options for Dev and Prod envs

func WithOutAndErrPaths

func WithOutAndErrPaths(o, e string) LogOption

WithOutAndErrPaths appends locations for stdout and stderr. This can be called as often as needed

func WithProduction

func WithProduction() LogOption

WithProduction sets some Production mode defaults

func WithSampling

func WithSampling(i, t int) LogOption

WithSampling sets sampling config

Jump to

Keyboard shortcuts

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