common

package
v4.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

README

Common Log Format Logger

This package enables logging using Common Log Format in go-restful apps.

Usage

Importing
import "github.com/AccelByte/go-restful-plugins/pkg/logger/common"
Log all endpoints
ws := new(restful.WebService)
ws.Filter(common.Log)
Log specific endpoint
ws := new(restful.WebService)
ws.Route(ws.GET("/user/{id}").
    Filter(common.Log).
    To(func(request *restful.Request, response *restful.Response) {
}))
Environment variables
FULL_ACCESS_LOG_ENABLED

Enable full access log mode. Default: false.

FULL_ACCESS_LOG_SUPPORTED_CONTENT_TYPES

Supported content types to shown in request_body and response_body log. Default: application/json,application/xml,application/x-www-form-urlencoded,text/plain,text/html.

FULL_ACCESS_LOG_MAX_BODY_SIZE

Maximum size of request body or response body that will be processed, will be ignored if exceed more than it. Default: 10240 bytes

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FullAccessLogEnabled               bool
	FullAccessLogSupportedContentTypes []string
	FullAccessLogMaxBodySize           int
)

Functions

func Log

func Log(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)

Log is a filter that will log incoming request into the defined Log format

Types

type ResponseWriterInterceptor added in v4.4.0

type ResponseWriterInterceptor struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

ResponseWriterInterceptor is used to decorate http.ResponseWriter, so we can intercept the Write process

func (*ResponseWriterInterceptor) Write added in v4.4.0

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

Jump to

Keyboard shortcuts

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