Skip to content

echo-logrus is a middleware that provides logrus logger support for echo.

License

Notifications You must be signed in to change notification settings

neko-neko/echo-logrus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

echo-logrus

Build Status Go Report Card License

Overview

Middleware echo-logrus is a logrus logger support for Echo.
This middleware is working on Echo v4.

Getting Started

For dep users

When your project top dir run this.

$ dep ensure -add github.com/neko-neko/echo-logrus

Modules users

$ go get github.com/neko-neko/echo-logrus/v2

Example

package main

import (
	"os"
	"time"

	"github.com/sirupsen/logrus"
	"github.com/labstack/echo/v4"
	echoLog "github.com/labstack/gommon/log"
	"github.com/neko-neko/echo-logrus/v2"
	"github.com/neko-neko/echo-logrus/v2/log"
)

func main() {
	e := echo.New()

	// Logger
	log.Logger().SetOutput(os.Stdout)
	log.Logger().SetLevel(echoLog.INFO)
	log.Logger().SetFormatter(&logrus.JSONFormatter{
		TimestampFormat: time.RFC3339,
	})
	e.Logger = log.Logger()
	e.Use(middleware.Logger())
	log.Info("Logger enabled!!")

	e.Logger.Fatal(e.Start(":1323"))
}