()
| 71 | func (srv *Server) registerDebugFeatures() {} |
| 72 | |
| 73 | func (srv *Server) registerAccessLogger() { |
| 74 | // Initialize a new request access log middleware, |
| 75 | // note that we use unbuffered data so we can have the results as fast as possible, |
| 76 | // this has its cost use it only on debug. |
| 77 | // Also, in the future see the iris example to |
| 78 | // enable log rotation (date eand filesize-based files). |
| 79 | ac := accesslog.FileUnbuffered(srv.config.RequestLog) |
| 80 | |
| 81 | // The default configuration: |
| 82 | ac.Delim = '|' |
| 83 | ac.TimeFormat = "2006-01-02 15:04:05" |
| 84 | ac.Async = false |
| 85 | ac.IP = true |
| 86 | ac.BytesReceivedBody = true |
| 87 | ac.BytesSentBody = true |
| 88 | ac.BytesReceived = false |
| 89 | ac.BytesSent = false |
| 90 | ac.BodyMinify = false |
| 91 | ac.RequestBody = true |
| 92 | ac.ResponseBody = false |
| 93 | ac.KeepMultiLineError = true |
| 94 | ac.PanicLog = accesslog.LogHandler |
| 95 | |
| 96 | // Default line format if formatter is missing: |
| 97 | // Time|Latency|Code|Method|Path|IP|Path Params Query Fields|Bytes Received|Bytes Sent|Request|Response| |
| 98 | // |
| 99 | // Set Custom Formatter: |
| 100 | ac.SetFormatter(&accesslog.JSON{ |
| 101 | Indent: " ", |
| 102 | HumanTime: true, |
| 103 | }) |
| 104 | |
| 105 | // ac.SetFormatter(&accesslog.CSV{}) |
| 106 | // ac.SetFormatter(&accesslog.Template{Text: "{{.Code}}"}) |
| 107 | |
| 108 | srv.UseRouter(ac.Handler) |
| 109 | } |
| 110 | |
| 111 | // Start runs the server on the TCP network address "0.0.0.0:port" which |
| 112 | // handles HTTP/1.1 & 2 requests on incoming connections. |
no test coverage detected