Skip to content

πŸ“– zap implementation of the Go Logger interface

License

Notifications You must be signed in to change notification settings

secondtruth/go-logger-zap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Go Logger interface – zap implementation

This library provides an implementation of the Logger interface for zap.

Installation

To install go-logger-zap, use the following command:

go get -u github.com/secondtruth/go-logger-zap

Quick Start

package main

import (
	"os"

	zaplogger "github.com/secondtruth/go-logger-zap/logger"
	"github.com/secondtruth/go-logger/logger"
	"go.uber.org/zap"
	"go.uber.org/zap/zapcore"
)

func main() {
	consoleEncoder := zapcore.NewJSONEncoder(zap.NewDevelopmentEncoderConfig())
	core := zapcore.NewCore(consoleEncoder,
		zapcore.Lock(zapcore.AddSync(os.Stderr)),
		zapcore.DebugLevel)
	zapLog := zap.New(core)
	log, _ := zaplogger.NewZapLogger(zapLog)

 	log.WithFields(logger.Fields{
		"foo": "bar",
	}).Info("message")
}