-
Notifications
You must be signed in to change notification settings - Fork 0
/
eventLog.go
40 lines (30 loc) · 1 KB
/
eventLog.go
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
32
33
34
35
36
37
38
39
40
package test
import (
"fmt"
"log"
fasthttp "github.com/Bofry/host-fasthttp"
"github.com/Bofry/host-fasthttp/response"
)
var _ fasthttp.EventLog = EventLog{}
type EventLog struct {
logger *log.Logger
evidence fasthttp.EventEvidence
}
func (l EventLog) OnError(ctx *fasthttp.RequestCtx, err interface{}, stackTrace []byte) {
l.logger.Printf("EventLog.OnError(): %v\n", err)
}
func (l EventLog) OnProcessRequest(ctx *fasthttp.RequestCtx) {
traceID := fmt.Sprintf("%s-%s",
l.evidence.RequestTraceID(),
l.evidence.RequestSpanID())
l.logger.Printf("EventLog.OnProcessRequest(): (%s) %s %s\n", traceID, ctx.Method(), ctx.Path())
}
func (l EventLog) OnProcessRequestComplete(ctx *fasthttp.RequestCtx, flag response.ResponseFlag) {
traceID := fmt.Sprintf("%s-%s",
l.evidence.RequestTraceID(),
l.evidence.RequestSpanID())
l.logger.Printf("EventLog.OnProcessRequestComplete(): (%s) %d [%v]\n", traceID, ctx.Response.StatusCode(), flag)
}
func (l EventLog) Flush() {
l.logger.Println("EventLog.Flush()")
}