log

package
v0.0.0-...-929c7af Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

package log see: https://github.com/uber-go/zap demo:

_ = log.New(false)
defer log.Sync()
log.Info("this is a test message")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DPanic

func DPanic(msg string, fields ...zap.Field)

DPanic DPanic means "development panic" Deprecated: 不建议采用

func Debug

func Debug(msg string, fields ...zap.Field)

func Error

func Error(msg string, fields ...zap.Field)

func Fatal

func Fatal(msg string, fields ...zap.Field)

func Info

func Info(msg string, fields ...zap.Field)

func Logger

func Logger() *zap.Logger

func New

func New(development bool)

func Panic

func Panic(msg string, fields ...zap.Field)

func SetLogger

func SetLogger(log *zap.Logger) error

func Sync

func Sync() error

func Warn

func Warn(msg string, fields ...zap.Field)

Types

type Config

type Config struct {
	// Level is the minimum enabled logging level. Note that this is a dynamic
	// level, so calling Config.Level.SetLevel will atomically change the log
	// level of all loggers descended from this config.
	Level zap.AtomicLevel `json:"level" yaml:"level"`
	// Development puts the logger in development mode, which changes the
	// behavior of DPanicLevel and takes stacktraces more liberally.
	Development bool `json:"development" yaml:"development"`
	// DisableCaller stops annotating logs with the calling function's file
	// name and line number. By default, all logs are annotated.
	// 调用 log方法 的文件名和行号
	DisableCaller bool `json:"disableCaller" yaml:"disableCaller"`
	// DisableStacktrace completely disables automatic stacktrace capturing. By
	// default, stacktraces are captured for WarnLevel and above logs in
	// development and ErrorLevel and above in production.
	DisableStacktrace bool `json:"disableStacktrace" yaml:"disableStacktrace"`
	// Sampling sets a sampling policy. A nil SamplingConfig disables sampling.
	// 日志记录限流
	// 每秒日志数量为Initial,如果超过,则每 Thereafter 条才记录
	// 每秒计数器会重置
	Sampling *zap.SamplingConfig `json:"sampling" yaml:"sampling"`
	// Encoding sets the logger's encoding. Valid values are "json" and
	// "console", as well as any third-party encodings registered via
	// RegisterEncoder.
	Encoder zapcore.Encoder

	WriteSyncer zapcore.WriteSyncer

	InitialFields map[string]interface{} `json:"initialFields" yaml:"initialFields"`
}

func NewDevelopment

func NewDevelopment() Config

func NewProduction

func NewProduction() Config

func (Config) Build

func (cfg Config) Build(opts ...zap.Option) *zap.Logger

Jump to

Keyboard shortcuts

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