glogrus

package module
v0.0.0-...-042cad4 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2017 License: MIT Imports: 6 Imported by: 0

README

goji/glogrus GoDoc

glogrus provides structured logging via logrus for Goji.

Example


package main

import(
	"github.com/zenazn/goji"
	"github.com/zenazn/goji/web/middleware"
	"github.com/goji/glogrus"
	"github.com/sirupsen/logrus"
)

func main() {
	goji.Abandon(middleware.Logger)

	logr := logrus.New()
	logr.Formatter = new(logrus.JSONFormatter)
	goji.Use(glogrus.NewGlogrus(logr, "my-app-name"))

	goji.Get("/ping", yourHandler)
	goji.Serve()
}


Looking for hierarchical structured logging?

slog and lunk looks interesting.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGlogrus

func NewGlogrus(l *logrus.Logger, name string) func(*web.C, http.Handler) http.Handler

NewGlogrus allows you to configure a goji middleware that logs all requests and responses using the structured logger logrus. It takes the logrus instance and the name of the app as the parameters and returns a middleware of type "func(c *web.C, http.Handler) http.Handler"

Example:

package main

import(
	"github.com/zenazn/goji"
	"github.com/zenazn/goji/web/middleware"
	"github.com/goji/glogrus"
	"github.com/sirupsen/logrus"
)

func main() {
	goji.Abandon(middleware.Logger)

	logr := logrus.New()
	logr.Formatter = new(logrus.JSONFormatter)
	goji.Use(glogrus.NewGlogrus(logr, "my-app-name"))

	goji.Get("/ping", yourHandler)
	goji.Serve()
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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