Documentation
¶
Index ¶
- func ContextKey() string
- func FromContext(ctx context.Context) *zap.SugaredLogger
- func Init(namespace, project, level string, writers ...zapcore.WriteSyncer)
- func Logger() *zap.SugaredLogger
- func NewContext(ctx context.Context, log *zap.SugaredLogger) context.Context
- func NewFileWriteSyncer(file string, size int) zapcore.WriteSyncer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 NewContext ¶
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.
Click to show internal directories.
Click to hide internal directories.