Documentation
¶
Index ¶
- func NewLogMiddleware(logger *logrus.Logger) fw.IMiddlewareCtl
- func NewLoggerMiddleware() fw.IMiddlewareGlobal
- type LogMiddleware
- type LogParams
- func (p *LogParams) ClientIPWithColor(f string) (string, color.Color)
- func (p *LogParams) LatencyWithColor(f string) (string, color.Color)
- func (p *LogParams) MethodWithColor(f string) (string, color.Color)
- func (p *LogParams) StatusCodeWithColor(f string) (string, color.Color)
- func (p *LogParams) TimeStampWithColor(f string) (string, color.Color)
- type LoggerMiddleware
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 (*LogParams) LatencyWithColor ¶
func (*LogParams) MethodWithColor ¶
func (*LogParams) StatusCodeWithColor ¶
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 ¶
func (w *LoggerMiddleware) Execute(ctx *fw.MiddlewareContext) fw.HandlerFunc
Click to show internal directories.
Click to hide internal directories.