An open API service indexing awesome lists of open source software.

https://github.com/secondtruth/go-logger-zap

📖 zap implementation of the Go Logger interface
https://github.com/secondtruth/go-logger-zap

interface interoperability logging zap

Last synced: 8 months ago
JSON representation

📖 zap implementation of the Go Logger interface

Awesome Lists containing this project

README

          

# Go Logger interface – zap implementation

This library provides an implementation of the [Logger interface](https://github.com/secondtruth/go-logger)
for [zap](https://github.com/uber-go/zap).

## Installation

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

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

## Quick Start

```go
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")
}
```