Logger for echo


package main

import (
    echolog ""

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

    server.Logger = echolog.NewLogger(logrus.StandardLogger(), "")
Expand ▾ Collapse ▴




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.