logger

package
v0.0.0-...-3cdf4da Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	yarf.Middleware
}

Logger middleware it's a simple log module that uses the default golang's log package. The log output writer can be defined by default with the log.SetOutput(w io.Writer) function. For more complex environments where a default logger can't be used across the system, a custom solution to replace this should be implemented.

func (*Logger) End

func (l *Logger) End(c *yarf.Context) error

func (*Logger) PreDispatch

func (l *Logger) PreDispatch(c *yarf.Context) error

PreDispatch wraps the http.ResponseWriter with a new LoggerWritter so we can log information about the response.

type LoggerWriter

type LoggerWriter struct {
	StatusCode int
	Writer     http.ResponseWriter
}

LoggerWriter will replace (wrap) the http.ResponseWriter to log all content written to the response.

func (*LoggerWriter) Header

func (lw *LoggerWriter) Header() http.Header

Header is a wrapper for http.ResponseWriter.Header()

func (*LoggerWriter) Write

func (lw *LoggerWriter) Write(content []byte) (int, error)

Write is a wrapper for

func (*LoggerWriter) WriteHeader

func (lw *LoggerWriter) WriteHeader(code int)

WriteHeader is a wrapper for http.ResponseWriter.WriteHeader() It saves the status code to be returned so we can log it.

Jump to

Keyboard shortcuts

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