onqlavelogger

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldCorrelationID = "cid"
	FieldError         = "error"
	FieldRootError     = "root_error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter interface {
	DoFilter(any) any
	IsFilter(string, any) bool
}

type Logger

type Logger struct {
	*zap.Logger
	// contains filtered or unexported fields
}

A Logger provides fast, leveled, structured logging. All methods are safe for concurrent use, along with filter policy to synthesis logging data.

func NewLog

func NewLog(name string, options ...Option) *Logger

NewLog create a new logger instance with default Zap logging production config and a logging scope based on the given name parameter. Custom logging option enables filter policy, correlationID and other configuration for logger. Logging is enabled at Info Level and above.

For further logging function. please refer to: https://pkg.go.dev/go.uber.org/zap

Example: Create a new logger with name "tenant-service", and filter policy to redact value from "email" fields. logger.NewLog("tenant-service", logger.WithFilters(filter.Field("email")))

func (*Logger) GetCid

func (l *Logger) GetCid() string

func (*Logger) WithCid

func (l *Logger) WithCid(cid string) *Logger

func (*Logger) WithErr

func (l *Logger) WithErr(err error) *Logger

func (*Logger) WithFields

func (l *Logger) WithFields(fields map[string]any) *Logger

type Option

type Option func(*Logger)

func WithCid

func WithCid(cid string) Option

func WithDevelopment

func WithDevelopment(isDevelop bool) Option

func WithDurationEncoder

func WithDurationEncoder(encoder zapcore.DurationEncoder) Option

func WithFilters

func WithFilters(filters ...Filter) Option

func WithLevel

func WithLevel(level zapcore.Level) Option

func WithTimeEncoder

func WithTimeEncoder(encoder zapcore.TimeEncoder) Option

Jump to

Keyboard shortcuts

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