ginzap

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ginzap provides a logging middleware to get https://github.com/uber-go/zap as logging library for https://github.com/gin-gonic/gin. It can be used as replacement for the internal logging middleware http://godoc.org/github.com/gin-gonic/gin#Logger.

This package is heavily based on https://github.com/szuecs/gin-glog

Example:

   package main
   import (
       "flag
       "time"
       "github.com/golang/glog"
       "github.com/akath19/gin-zap"
       "github.com/gin-gonic/gin"
   )
   func main() {
       flag.Parse()
       router := gin.New()
	      logger := zap.NewProduction()
       router.Use(ginzap.Logger(3 * time.Second, logger))
       //..
       router.Use(gin.Recovery())
		  logger.Info("Gin bootstrapped with Zap")
       router.Run(":8080")
   }

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorLogger

func ErrorLogger() gin.HandlerFunc

ErrorLogger returns a gin handler func for errors

func ErrorLoggerT

func ErrorLoggerT(t gin.ErrorType) gin.HandlerFunc

ErrorLoggerT returns a gin handler middleware with the given type gin.ErrorType.

func Logger

func Logger(logger *zap.Logger) gin.HandlerFunc

Logger returns a gin handler func for all logging

Types

This section is empty.

Jump to

Keyboard shortcuts

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