gin

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: MIT Imports: 3 Imported by: 0

README

Logger for gin

Example

package main

import (
    "github.com/gin-gonic/gin"
    ginlog "github.com/onrik/logrus/gin"
    "github.com/sirupsen/logrus"
)

func main() {
    server := gin.New()

    server.Use(ginlog.Middleware(ginlog.DefaultConfig))
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultConfig = Config{
		Logger: logrus.StandardLogger(),
		Fields: []string{"ip", "latency", "status"},
	}
)

Functions

func Middleware

func Middleware(config Config) gin.HandlerFunc

Types

type Config

type Config struct {
	Logger *logrus.Logger

	// Fields available for logging
	// - id (Request ID)
	// - ip
	// - host
	// - referer
	// - user_agent
	// - status
	// - latency
	// - headers
	Fields []string
}

Jump to

Keyboard shortcuts

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