goyave: github.com/System-Glitch/goyave/log Index | Files

package log

import "github.com/System-Glitch/goyave/log"

Index

Package Files

common.go log.go

Constants

const (
    // Format is the fmt format code for common logs
    Format string = "%s %s %s [%s] \"%s %s %s\" %d %d"

    // TimestampFormat is the time format used in common logs
    TimestampFormat string = "02/Jan/2006:15:04:05 -0700"
)

func CombinedLogFormatter Uses

func CombinedLogFormatter(now time.Time, response *goyave.Response, request *goyave.Request, length int) string

CombinedLogFormatter build a log entry using the Combined Log Format.

func CombinedLogMiddleware Uses

func CombinedLogMiddleware() goyave.Middleware

CombinedLogMiddleware captures response data and outputs it to the default logger using the combined log format.

func CommonLogFormatter Uses

func CommonLogFormatter(now time.Time, response *goyave.Response, request *goyave.Request, length int) string

CommonLogFormatter build a log entry using the Common Log Format.

func CommonLogMiddleware Uses

func CommonLogMiddleware() goyave.Middleware

CommonLogMiddleware captures response data and outputs it to the default logger using the common log format.

func Middleware Uses

func Middleware(formatter Formatter) goyave.Middleware

Middleware captures response data and outputs it to the default logger using the given formatter.

type Formatter Uses

type Formatter func(now time.Time, response *goyave.Response, request *goyave.Request, length int) string

Formatter is a function that builds a log entry. As logs are written at the end of the request's lifecycle, all the data is available to formatters at the time they are called, and all modifications will have no effect.

type Writer Uses

type Writer struct {
    // contains filtered or unexported fields
}

Writer chained writer keeping response body in memory. Used for loggin in common format.

func NewWriter Uses

func NewWriter(response *goyave.Response, request *goyave.Request, formatter Formatter) *Writer

NewWriter create a new LogWriter. The given Request and Response will be used and passed to the given formatter.

func (*Writer) Close Uses

func (w *Writer) Close() error

Close the writer and its child ResponseWriter, flushing response output to the logs.

func (*Writer) PreWrite Uses

func (w *Writer) PreWrite(b []byte)

PreWrite calls PreWrite on the child writer if it implements PreWriter.

func (*Writer) Write Uses

func (w *Writer) Write(b []byte) (int, error)

Write writes the data as a response and keeps it in memory for later logging.

Package log imports 6 packages (graph). Updated 2020-09-12. Refresh now. Tools for package owners.