zapwrap

package module
v0.0.0-...-f10f904 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2016 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

#ZapWrap

ZapWrap is a very simple wrapper that allows you to use a Zap logger with the Echo framework, or anything else expecting a similar logging interface.

Neither Zap nor Echov2 have stable APIs at this point so this may break and should probably not be used in production at this time. This code itself is also not very well tested either, but it is pretty trivial.

#Example

package main

import (
        "github.com/jmunson/zapwrap"
        "github.com/labstack/echo"
        "github.com/uber-go/zap"
)

func main() {
        e := echo.New()
        log := zap.NewJSON()
        e.SetLogger(zapwrap.Wrap(log))
        e.Logger().Info("Hello!")
        //continue to use both echo and your zap logger as normal
}

Documentation

Overview

zapwrap wraps a zap logger into the interface the Echo framework is expecting

Index

Constants

View Source
const (
	// PanicLevel level, highest level of severity. Logs and then calls panic with the
	// message passed to Debug, Info, ...
	PanicLevel uint8 = iota
	// FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the
	// logging level is set to Panic.
	FatalLevel
	// ErrorLevel level. Logs. Used for errors that should definitely be noted.
	// Commonly used for hooks to send errors to an error tracking service.
	ErrorLevel
	// WarnLevel level. Non-critical entries that deserve eyes.
	WarnLevel
	// InfoLevel level. General operational entries about what's going on inside the
	// application.
	InfoLevel
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel
)

These are the level consts from logrus, which I assume echo is using based on it being uint8s I could just reference these from logrus's package but that seems like it might be fragile and causes a dependency we shouldn't need.

Variables

This section is empty.

Functions

func Wrap

func Wrap(l zap.Logger) wrappedLogger

Types

This section is empty.

Jump to

Keyboard shortcuts

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