-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathlog.go
More file actions
31 lines (26 loc) · 685 Bytes
/
log.go
File metadata and controls
31 lines (26 loc) · 685 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package goflow
import (
"fmt"
"time"
"github.com/gin-gonic/gin"
)
// DefaultLogger returns the default logging middleware.
func DefaultLogger() gin.HandlerFunc {
return gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string {
return fmt.Sprintf("%s [GOFLOW] - \"%s %s %s %d %s \"%s\" %s\"\n",
param.TimeStamp.Format(time.RFC3339),
param.Method,
param.Path,
param.Request.Proto,
param.StatusCode,
param.Latency,
param.Request.UserAgent(),
param.ErrorMessage,
)
})
}
type logWriter struct {
}
func (writer logWriter) Write(bytes []byte) (int, error) {
return fmt.Print(time.Now().Format(time.RFC3339) + " [GOFLOW] - " + string(bytes))
}