log

package
v0.1.71 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: Apache-2.0 Imports: 12 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) (*Config, 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 Code added in v0.1.66

func Code(err error) Field

Code constructs a field with the given value and code key

func Error

func Error(err error) Field

Error constructs a field with the given value and error key

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