Version: v0.7.1 Latest Latest

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

Go to latest
Published: Jul 14, 2020 License: MIT Imports: 5 Imported by: 0


Logger for echo


package main

import (
    echolog ""

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

    server.Logger = echolog.NewLogger(logrus.StandardLogger(), "")




This section is empty.


View Source
var (
	// DefaultConfig is the default Logger middleware config.
	DefaultConfig = Config{
		Logger:  logrus.StandardLogger(),
		Skipper: func(c echo.Context) bool { return false },
		Fields:  []string{"ip", "latency", "status"},
		Status:  0,


func Middleware

func Middleware(config Config) echo.MiddlewareFunc

Middleware returns a Logger middleware with config.


type Config

type Config struct {
	Logger *logrus.Logger
	// Skipper defines a function to skip middleware.
	Skipper Skipper

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

Config defines the config for Logger middleware.

type Logger

type Logger struct {

	MsgField string
	// contains filtered or unexported fields

func NewLogger

func NewLogger(l *logrus.Logger, prefix string) *Logger

NewLogger creates logger

func (*Logger) Debugj

func (l *Logger) Debugj(j log.JSON)

func (*Logger) Errorj

func (l *Logger) Errorj(j log.JSON)

func (*Logger) Fatalj

func (l *Logger) Fatalj(j log.JSON)

func (*Logger) Infoj

func (l *Logger) Infoj(j log.JSON)

func (*Logger) Level

func (l *Logger) Level() log.Lvl

func (*Logger) Output

func (l *Logger) Output() io.Writer

func (*Logger) Panicj

func (l *Logger) Panicj(j log.JSON)

func (*Logger) Prefix

func (l *Logger) Prefix() string

func (*Logger) Printj

func (l *Logger) Printj(j log.JSON)

func (*Logger) SetHeader

func (l *Logger) SetHeader(h string)

func (*Logger) SetLevel

func (l *Logger) SetLevel(lvl log.Lvl)

func (*Logger) SetOutput

func (l *Logger) SetOutput(w io.Writer)

func (*Logger) SetPrefix

func (l *Logger) SetPrefix(prefix string)

func (*Logger) Warnj

func (l *Logger) Warnj(j log.JSON)

type Skipper

type Skipper func(c echo.Context) bool

Skipper defines a function to skip middleware.

Jump to

Keyboard shortcuts

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