loghttp

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	REQEUST_ID = "_REQEUST_ID"

	LogReqHeaderKey  = "neve.web.log.requestHeader"
	LogReqBodyKey    = "neve.web.log.requestBody"
	LogRespHeaderKey = "neve.web.log.responseHeader"
	LogRespBodyKey   = "neve.web.log.responseBody"
	LogLevelKey      = "neve.web.log.level"

	LogLevelDebug = "debug"
	LogLevelInfo  = "info"
	LogLevelWarn  = "warn"
	LogLevelError = "error"
	LogLevelPanic = "panic"
	LogLevelFatal = "fatal"
)

Variables

This section is empty.

Functions

func NewFromConfig added in v0.0.5

func NewFromConfig(conf fig.Properties, logger xlog.Logger) *hLogger

func NewHttpLogger

func NewHttpLogger(logger xlog.Logger, opts ...LogOpt) *hLogger

Types

type DefaultHttpLogger

type DefaultHttpLogger LogHttpUtil

type HttpLogger

type HttpLogger interface {
	// 获得按配置初始化的日志handler
	LogHttp() gin.HandlerFunc
	// 按参数配置日志handler
	OptLogHttp(opts ...LogOpt) gin.HandlerFunc
	// 根据参数配置Clone出新的HttpLogger
	Clone(opts ...LogOpt) HttpLogger
}

type LogHttpUtil

type LogHttpUtil struct {
	Logger xlog.Logger

	// with request header log
	LogReqHeader bool `fig:"log.requestHeader"`
	// with request body log
	LogReqBody bool `fig:"log.requestBody"`
	// with response header log
	LogRespHeader bool `fig:"log.responseHeader"`
	// with response body log
	LogRespBody bool `fig:"log.responseBody"`
	// log level
	Level string `fig:"log.level"`
	// contains filtered or unexported fields
}

func NewLogHttpUtil

func NewLogHttpUtil(conf fig.Properties, logger xlog.Logger) *LogHttpUtil

func (*LogHttpUtil) Clone added in v0.0.5

func (util *LogHttpUtil) Clone(opts ...LogOpt) HttpLogger

func (*LogHttpUtil) LogHttp

func (util *LogHttpUtil) LogHttp() gin.HandlerFunc

func (*LogHttpUtil) OptLogHttp

func (util *LogHttpUtil) OptLogHttp(opts ...LogOpt) gin.HandlerFunc

func (*LogHttpUtil) Set

func (util *LogHttpUtil) Set(key string, value interface{})

type LogOpt

type LogOpt func(setter Setter)

func DisableLogReqBody

func DisableLogReqBody() LogOpt

func DisableLogReqHeader

func DisableLogReqHeader() LogOpt

func DisableLogRespBody

func DisableLogRespBody() LogOpt

func DisableLogRespHeader

func DisableLogRespHeader() LogOpt

func EnableLogReqBody

func EnableLogReqBody() LogOpt

func EnableLogReqHeader

func EnableLogReqHeader() LogOpt

func EnableLogRespBody

func EnableLogRespBody() LogOpt

func EnableLogRespHeader

func EnableLogRespHeader() LogOpt

func OptLogLevel

func OptLogLevel(lv string) LogOpt

func OptLogReqBody

func OptLogReqBody(flag bool) LogOpt

func OptLogReqHeader

func OptLogReqHeader(flag bool) LogOpt

func OptLogRespBody

func OptLogRespBody(flag bool) LogOpt

func OptLogRespHeader

func OptLogRespHeader(flag bool) LogOpt

type RequestBodyLogWriter

type RequestBodyLogWriter struct {
	Logger xlog.Logger
	V      binding.StructValidator
}

func (*RequestBodyLogWriter) Engine

func (v *RequestBodyLogWriter) Engine() interface{}

func (*RequestBodyLogWriter) ValidateStruct

func (v *RequestBodyLogWriter) ValidateStruct(obj interface{}) error

type Setter

type Setter interface {
	Set(key string, value interface{})
}

Jump to

Keyboard shortcuts

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