README

zap logger adapter

Build Status Coverage Status GoDoc Go Report Card Release

This package is an adapter of universal logger interface for zap.

Usage

import (
    "github.com/clevergo/log"
    zapadapter "github.com/clevergo/log-zap"
    "go.uber.org/zap"
)

var logger log.Logger

func main() {
    zapLogger, err := zap.NewDevelopment(zap.AddCallerSkip(1))
    if err != nil {
        panic(err)
    }
    logger := New(zapLogger.Sugar())
    logger.Debug("debug msg")
    // ...
}
Expand ▾ Collapse ▴

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(sugaredLogger *zap.SugaredLogger) log.Logger

New returns a logger.

Example

Code:

zapLogger, err := zap.NewDevelopment(zap.AddCallerSkip(1))
if err != nil {
	panic(err)
}
logger := New(zapLogger.Sugar())
logger.Debug("debug")
logger.Debugf("debugf")
logger.Debugln("debugln")

logger.Info("info")
logger.Infof("infof")
logger.Infoln("infoln")

logger.Warn("warn")
logger.Warnf("warnf")
logger.Warnln("warnln")

logger.Error("error")
logger.Errorf("errorf")
logger.Errorln("errorln")

//logger.Fatal("fatal")
//logger.Fatalf("fatalf")
//logger.Fatalln("fatalln")

Types

This section is empty.

Source Files