logger

package
v0.0.0-...-d840a7c Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func New

func New(c Config, fields ...Field) *zap.Logger

New create a new Sugared logger

func NewEncoderConfig

func NewEncoderConfig() zapcore.EncoderConfig

NewEncoderConfig creates logger config for debug mode

func ParseLevel

func ParseLevel(level string) (zapcore.Level, error)

ParseLevel parses string to zap level

func TimeEncoder

func TimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)

Types

type Config

type Config struct {
	Path       string `yaml:"path" json:"path"`
	Level      string `yaml:"level" json:"level" default:"info" validate:"regexp=^(info|debug|warn|error)$"`
	Encoding   string `yaml:"encoding" json:"encoding" default:"json" validate:"regexp=^(json|console)$"`
	Format     string `yaml:"format" json:"format" default:"text" validate:"regexp=^(text|json)$"`
	MaxAge     int    `yaml:"maxAge" json:"maxAge" default:"15" validate:"min=1"`   // days
	MaxSize    int    `yaml:"maxSize" json:"maxSize" default:"50" validate:"min=1"` // MB
	MaxBackups int    `yaml:"maxBackups" json:"maxBackups" default:"15" validate:"min=1"`
}

LogConfig for logging

type Field

type Field = zap.Field

func Any

func Any(key string, val interface{}) Field

Any constructs a field with the given key and value

func Error

func Error(err error) Field

func String

func String(key string, val string) Field

type Level

type Level = zapcore.Level

Level log level

const (
	DebugLevel Level = iota - 1
	InfoLevel
	WarnLevel
	ErrorLevel
	PanicLevel
	FatalLevel
)

all log level

type Logger

type Logger = zap.Logger

func With

func With(fields ...Field) *Logger

With creates a child logger and adds structured context to it. Fields added to the child don't affect the parent, and vice versa.

Jump to

Keyboard shortcuts

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