logrus_zap_hook

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2019 License: MIT Imports: 4 Imported by: 5

README

Zap Hook for Logrus

Use this hook to send logs from logrus to zap. All levels are sent by default.

Usage

package main

import (
    "io/ioutil"
    
    zaphook "github.com/Sytten/logrus-zap-hook"
    "github.com/sirupsen/logrus"
    "go.uber.org/zap"
)

func main() {
    log := logrus.New()
    log.ReportCaller = true // So Zap reports the right caller
    log.SetOutput(ioutil.Discard) // Prevent logrus from writing its logs
    
    logger, _ := zap.NewDevelopment()
    hook, _ := zaphook.NewZapHook(logger)
    
    log.Hooks.Add(hook)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ZapHook

type ZapHook struct {
	Logger *zap.Logger
}

func NewZapHook

func NewZapHook(logger *zap.Logger) (*ZapHook, error)

func (*ZapHook) Fire

func (hook *ZapHook) Fire(entry *logrus.Entry) error

func (*ZapHook) Levels

func (hook *ZapHook) Levels() []logrus.Level

func (*ZapHook) Write

func (hook *ZapHook) Write(lvl zapcore.Level, msg string, fields []zap.Field, caller *runtime.Frame)

Jump to

Keyboard shortcuts

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