go-json-spec-handler: github.com/derekdowling/go-json-spec-handler/goji2-logger Index | Files

package gojilogger

import "github.com/derekdowling/go-json-spec-handler/goji2-logger"


Package Files

color_writer.go logger.go


const (
    // FastResponse is anything under this duration
    FastResponse = 500 * time.Millisecond
    // AcceptableResponse is anything under this duration
    AcceptableResponse = 5 * time.Second

type Logger Uses

type Logger struct {
    // Logger is a https://github.com/derekdowling/go-stdlogger
    Logger std.Logger
    // Debug will increase verbosity of logging information, and causes Query params not
    // to be omitted. Do NOT use in production otherwise you risk logging sensitive
    // information.
    Debug bool

Logger contains instance state for a goji2logger to avoid configuration collisions if this middleware is used in multiple places

func New Uses

func New(logger std.Logger, debug bool) *Logger

New creates a new goji2logger instance

func (*Logger) Middleware Uses

func (l *Logger) Middleware(next http.Handler) http.Handler

Middleware logs the start and end of each request, along with some useful data about what was requested, what the response status was, and how long it took to return. When standard output is a TTY, Logger will print in color, otherwise it will print in black and white.

Use like so with Goji2:

gLogger := gojilogger.New(nil, false)

Package gojilogger imports 10 packages (graph) and is imported by 1 packages. Updated 2017-06-30. Refresh now. Tools for package owners.