log

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2020 License: Apache-2.0 Imports: 10 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Path   string `yaml:"path" json:"path"`
	Level  string `yaml:"level" json:"level" default:"info" validate:"regexp=^(fatal|panic|error|warn|info|debug)$"`
	Format string `yaml:"format" json:"format" default:"text" validate:"regexp=^(text|json)$"`
	Age    struct {
		Max int `yaml:"max" json:"max" default:"15" validate:"min=1"`
	} `yaml:"age" json:"age"` // days
	Size struct {
		Max int `yaml:"max" json:"max" default:"50" validate:"min=1"`
	} `yaml:"size" json:"size"` // in MB
	Backup struct {
		Max int `yaml:"max" json:"max" default:"15" validate:"min=1"`
	} `yaml:"backup" json:"backup"`
}

Config for logging

func (*Config) String

func (c *Config) String() string

type Field

type Field = zap.Field

Field log 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

Error is shorthand for the common idiom NamedError("error", err).

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

Logger logger

func Init

func Init(c Config, fields ...Field) (*Logger, error)

Init init and return 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.

type Option

type Option = zap.Option

Option log Option

Jump to

Keyboard shortcuts

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