echo

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: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Logger for echo

Example

package main

import (
    "github.com/labstack/echo/v4"
    echolog "github.com/onrik/logrus/echo"
    "github.com/sirupsen/logrus"
)

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

    server.Logger = echolog.NewLogger(logrus.StandardLogger(), "")
    server.Use(echolog.Middleware(echolog.DefaultConfig))
}

Documentation

Index

Constants

This section is empty.

Variables

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,
	}
)

Functions

func Middleware

func Middleware(config Config) echo.MiddlewareFunc

Middleware returns a Logger middleware with config.

Types

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 {
	*logrus.Logger

	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