MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / log

Method log

internal/nodes/http_request_log.go:16–188  ·  view source on GitHub ↗

日志

()

Source from the content-addressed store, hash-verified

14
15// 日志
16func (this *HTTPRequest) log() {
17 // 检查全局配置
18 if this.nodeConfig != nil && this.nodeConfig.GlobalServerConfig != nil && !this.nodeConfig.GlobalServerConfig.HTTPAccessLog.IsOn {
19 return
20 }
21
22 var ref *serverconfigs.HTTPAccessLogRef
23 if !this.forceLog {
24 if this.disableLog {
25 return
26 }
27
28 // 计算请求时间
29 this.requestCost = time.Since(this.requestFromTime).Seconds()
30
31 ref = this.web.AccessLogRef
32 if ref == nil {
33 ref = serverconfigs.DefaultHTTPAccessLogRef
34 }
35 if !ref.IsOn {
36 return
37 }
38
39 if !ref.Match(this.writer.StatusCode()) {
40 return
41 }
42
43 if ref.FirewallOnly && this.firewallPolicyId == 0 {
44 return
45 }
46
47 // 是否记录499
48 if !ref.EnableClientClosed && this.writer.StatusCode() == 499 {
49 return
50 }
51 }
52
53 var addr = this.RawReq.RemoteAddr
54 var index = strings.LastIndex(addr, ":")
55 if index > 0 {
56 addr = addr[:index]
57 }
58
59 var serverGlobalConfig = this.nodeConfig.GlobalServerConfig
60
61 // 请求Cookie
62 var cookies = map[string]string{}
63 var enableCookies = false
64 if serverGlobalConfig == nil || serverGlobalConfig.HTTPAccessLog.EnableCookies {
65 enableCookies = true
66 if ref == nil || ref.ContainsField(serverconfigs.HTTPAccessLogFieldCookie) {
67 for _, cookie := range this.RawReq.Cookies() {
68 cookies[cookie.Name] = cookie.Value
69 }
70 }
71 }
72
73 // 请求Header

Callers 1

doEndMethod · 0.95

Calls 15

requestQueryStringMethod · 0.95
requestRemoteAddrMethod · 0.95
requestRemotePortMethod · 0.95
requestRemoteUserMethod · 0.95
PathMethod · 0.95
requestLengthMethod · 0.95
requestFilenameMethod · 0.95
requestSchemeMethod · 0.95
requestStringMethod · 0.95
requestServerPortMethod · 0.95
SentBodyBytesMethod · 0.80
UnixMethod · 0.80

Tested by

no test coverage detected