Documentation ¶
Index ¶
- func ErrorLoggerT(typ gin.ErrorType) gin.HandlerFunc
- func New(opts ...Option) gin.HandlerFunc
- func NewErrorLogger(opts ...Option) gin.HandlerFunc
- func SetGinDefaultWriter(logger glog.ILogger)
- type LogFormatter
- type LogFormatterParams
- type Option
- func WithConsoleColor(consoleColor bool) Option
- func WithEndpointLabelMappingFn(endpointLabelMappingFn RequestLabelMappingFn) Option
- func WithExcludeRegexEndpoint(excludeRegexEndpoint []string) Option
- func WithExcludeRegexMethod(excludeRegexMethod []string) Option
- func WithExcludeRegexStatus(excludeRegexStatus []string) Option
- func WithFormatter(formatter LogFormatter) Option
- func WithLogger(logger glog.ILogger) Option
- func WithWriterErrorFn(fn WriterErrorFn) Option
- func WithWriterLogFn(fn WriterLogFn) Option
- type RequestLabelMappingFn
- type WriterErrorFn
- type WriterLogFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorLoggerT ¶
func ErrorLoggerT(typ gin.ErrorType) gin.HandlerFunc
ErrorLoggerT returns a handler func for a given error type.
func New ¶
func New(opts ...Option) gin.HandlerFunc
New instances a Logger middleware that will write the logs to gin.DefaultWriter. By default gin.DefaultWriter = os.Stdout.
func NewErrorLogger ¶ added in v0.2.9
func NewErrorLogger(opts ...Option) gin.HandlerFunc
NewErrorLogger returns a handler func for any error type.
func SetGinDefaultWriter ¶
Types ¶
type LogFormatter ¶
type LogFormatter func(params LogFormatterParams) string
LogFormatter gives the signature of the formatter function passed to LoggerWithFormatter
type LogFormatterParams ¶
type LogFormatterParams struct { // TimeStamp shows the time after the webServe returns a response. TimeStamp time.Time // StatusCode is HTTP response code. StatusCode int // Latency is how much time the webServe cost to process a certain request. Latency time.Duration // ClientIP equals Context's ClientIP method. ClientIP string // Method is the HTTP method given to the request. Method string // Path is a path the client requests. Path string // ErrorMessage is set if error has occurred in processing the request. ErrorMessage string // BodySize is the size of the Response Body BodySize int // Keys are the keys set on the request's context. Keys map[string]interface{} RequestData string RequestUserAgent string RequestReferer string RequestProto string RequestId string TraceId string SpanId string ResponseData string // contains filtered or unexported fields }
LogFormatterParams is the structure any formatter will be handed when time to log comes
func (*LogFormatterParams) IsOutputColor ¶
func (p *LogFormatterParams) IsOutputColor() bool
IsOutputColor indicates whether can colors be outputted to the log.
func (*LogFormatterParams) MethodColor ¶
func (p *LogFormatterParams) MethodColor() string
MethodColor is the ANSI color for appropriately logging http method to a terminal.
func (*LogFormatterParams) ResetColor ¶
func (p *LogFormatterParams) ResetColor() string
ResetColor resets all escape attributes.
func (*LogFormatterParams) StatusCodeColor ¶
func (p *LogFormatterParams) StatusCodeColor() string
StatusCodeColor is the ANSI color for appropriately logging http status code to a terminal.
type Option ¶
type Option func(*config)
Option for queue system
func WithConsoleColor ¶
WithConsoleColor set consoleColor function
func WithEndpointLabelMappingFn ¶
func WithEndpointLabelMappingFn(endpointLabelMappingFn RequestLabelMappingFn) Option
WithEndpointLabelMappingFn set endpointLabelMappingFn function
func WithExcludeRegexEndpoint ¶
WithExcludeRegexEndpoint set excludeRegexEndpoint function regexp
func WithExcludeRegexMethod ¶
WithExcludeRegexMethod set excludeRegexMethod function regexp
func WithExcludeRegexStatus ¶
WithExcludeRegexStatus set excludeRegexStatus function regexp
func WithFormatter ¶
func WithFormatter(formatter LogFormatter) Option
WithFormatter set formatter function
func WithWriterErrorFn ¶ added in v0.2.9
func WithWriterErrorFn(fn WriterErrorFn) Option
WithWriterErrorFn set fn WriterErrorFn
func WithWriterLogFn ¶ added in v0.2.9
func WithWriterLogFn(fn WriterLogFn) Option
WithWriterLogFn set fn WriterLogFn
type RequestLabelMappingFn ¶
type WriterErrorFn ¶ added in v0.2.9
type WriterErrorFn func(c *gin.Context, log *LogFormatterParams) (int, interface{})
type WriterLogFn ¶ added in v0.2.9
type WriterLogFn func(c *gin.Context, log *LogFormatterParams)