log

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogMiddleware

func NewLogMiddleware(logger *logrus.Logger) fw.IMiddlewareCtl

func NewLoggerMiddleware

func NewLoggerMiddleware() fw.IMiddlewareGlobal

Types

type LogMiddleware

type LogMiddleware struct {
	*fw.MiddlewareCtl
	Logger *logrus.Logger `inject:""`
	// contains filtered or unexported fields
}

LogMiddleware for logging request info. can be used on Controller or Method

func (*LogMiddleware) Execute

func (w *LogMiddleware) Execute(ctx *fw.MiddlewareContext) fw.HandlerFunc

type LogParams

type LogParams struct {
	// TimeStamp shows the time after the server returns a response.
	TimeStamp time.Time
	// StatusCode is HTTP response code.
	StatusCode int
	// Latency is how much time the server 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]any

	Protocol  string
	UserAgent string
}

func (*LogParams) ClientIPWithColor

func (p *LogParams) ClientIPWithColor(f string) (string, color.Color)

func (*LogParams) LatencyWithColor

func (p *LogParams) LatencyWithColor(f string) (string, color.Color)

func (*LogParams) MethodWithColor

func (p *LogParams) MethodWithColor(f string) (string, color.Color)

func (*LogParams) StatusCodeWithColor

func (p *LogParams) StatusCodeWithColor(f string) (string, color.Color)

func (*LogParams) TimeStampWithColor

func (p *LogParams) TimeStampWithColor(f string) (string, color.Color)

type LoggerMiddleware

type LoggerMiddleware struct {
	*fw.MiddlewareGlobal
	Logger types.ILogger `inject:""`
}

func (*LoggerMiddleware) DoInitOnce added in v0.2.4

func (w *LoggerMiddleware) DoInitOnce()

func (*LoggerMiddleware) Execute

Jump to

Keyboard shortcuts

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