logrusmiddleware

package module
v0.0.0-...-83c3e63 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2019 License: MIT Imports: 6 Imported by: 0

README

echo-logrusmiddleware

logrus middleware

An adapter (middleware) to make the Golang Echo web framework logging work with logrus, an excellent logging solution.

Install

$ go get github.com/pennstate/echo-logrusmiddleware

Usage

package main

import (
	"github.com/sirupsen/logrus"
	"github.com/labstack/echo"
	elm "github.com/pennstate/echo-logrusmiddleware"
)

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

	// echo Logger interface friendly wrapper around logrus logger to use it
	// for default echo logger
	e.Logger = elm.Logger{logrus.StandardLogger()}
	e.Use(elm.Hook())

	// do the rest of your echo setup, routes, listen on server, etc..
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hook

func Hook() echo.MiddlewareFunc

Hook returns an echo.MiddlewareFunc that logs desired information using the logrus StandardLogger

Types

type Logger

type Logger struct {
	*logrus.Logger
}

Logger bridges the echo.Logger interface to use sirupsen.Logrus as the implementation

func (Logger) Debugj

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

Debugj logs with fields at debug

func (Logger) Errorj

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

Errorj logs with fields at error

func (Logger) Fatalj

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

Fatalj logs with fields at fatal

func (Logger) Infoj

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

Infoj logs with fields at info

func (Logger) Level

func (l Logger) Level() log.Lvl

Level gets the current logging level

func (Logger) Output

func (l Logger) Output() io.Writer

Output gets the output

func (Logger) Panicj

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

Panicj logs with fields at panic

func (Logger) Prefix

func (l Logger) Prefix() string

Prefix is not supported and returns an empty string

func (Logger) Printj

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

Printj prints with fields

func (Logger) SetHeader

func (l Logger) SetHeader(header string)

SetHeader is not supported and is a NOOP

func (Logger) SetLevel

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

SetLevel sets the logging level

func (Logger) SetOutput

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

SetOutput sets the output

func (Logger) SetPrefix

func (l Logger) SetPrefix(s string)

SetPrefix is not supported and is a NOOP

func (Logger) Warnj

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

Warnj logs with fields at warn

Jump to

Keyboard shortcuts

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