Back to godoc.org

Package logger

v0.0.0-...-d840a7c
Latest Go to latest

The latest major version is .

Published: Apr 16, 2020 | License: Apache-2.0 | Module: github.com/aiicy/aiicy-go

Index

Variables

var L *zap.Logger

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)

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.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier