log

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextKey

func ContextKey() string

ContextKey return

func FromContext

func FromContext(ctx context.Context) *zap.SugaredLogger

FromContext return log from ctx

func Init

func Init(namespace, project, level string, writers ...zapcore.WriteSyncer)

Init 初始化 logger 对象 若未指定或指定 level 不存在,则 level = info 若未设置 writers 则 输出到 标准输出 eg: log.Init("group-name", "project-name", "debug", os.Stdout, log.NewFileWriteSyncer("/tmp/group-project.log", 100))

func Logger

func Logger() *zap.SugaredLogger

Logger 获取全局logger 对象;需要先初始化

func NewContext

func NewContext(ctx context.Context, log *zap.SugaredLogger) context.Context

NewContext return new context with a *zap.SugaredLogger inside 若将 log 保存在 gin.Context 中:

// c = *gin.Context
c.Set(log.ContextKey(), logger)

func NewFileWriteSyncer

func NewFileWriteSyncer(file string, size int) zapcore.WriteSyncer

NewFileWriteSyncer 文件输出器

Types

This section is empty.

Jump to

Keyboard shortcuts

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