log

package
v0.1.61 Latest Latest
Warning

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

Go to latest
Published: May 26, 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 {
	Level      string `yaml:"level" json:"level" default:"info" validate:"regexp=^(fatal|panic|error|warn|info|debug)$"`
	Encoding   string `yaml:"encoding" json:"encoding" default:"json" validate:"regexp=^(json|console)$"`
	Filename   string `yaml:"filename" json:"filename"`
	Compress   bool   `yaml:"compress" json:"compress"`
	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"`
}

Config for logging

func FromURL added in v0.1.9

func FromURL(u *url.URL) (c Config, err error)

FromURL creates config from url

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(cfg Config, fields ...Field) (*Logger, error)

Init init and return logger

func L added in v0.1.9

func L() *Logger

L returns the global Logger, which can be reconfigured with ReplaceGlobals. It's safe for concurrent use.

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