MCPcopy
hub / github.com/beego/beego / LogAccess

Method LogAccess

server/web/server.go:860–893  ·  view source on GitHub ↗
(ctx *beecontext.Context, startTime *time.Time, statusCode int)

Source from the content-addressed store, hash-verified

858}
859
860func (app *HttpServer) LogAccess(ctx *beecontext.Context, startTime *time.Time, statusCode int) {
861 // Skip logging if AccessLogs config is false
862 if !app.Cfg.Log.AccessLogs {
863 return
864 }
865 // Skip logging static requests unless EnableStaticLogs config is true
866 if !app.Cfg.Log.EnableStaticLogs && DefaultAccessLogFilter.Filter(ctx) {
867 return
868 }
869 var (
870 requestTime time.Time
871 elapsedTime time.Duration
872 r = ctx.Request
873 )
874 if startTime != nil {
875 requestTime = *startTime
876 elapsedTime = time.Since(*startTime)
877 }
878 record := &logs.AccessLogRecord{
879 RemoteAddr: ctx.Input.IP(),
880 RequestTime: requestTime,
881 RequestMethod: r.Method,
882 Request: fmt.Sprintf("%s %s %s", r.Method, r.RequestURI, r.Proto),
883 ServerProtocol: r.Proto,
884 Host: r.Host,
885 Status: statusCode,
886 ElapsedTime: elapsedTime,
887 HTTPReferrer: r.Header.Get("Referer"),
888 HTTPUserAgent: r.Header.Get("User-Agent"),
889 RemoteUser: r.Header.Get("Remote-User"),
890 BodyBytesSent: r.ContentLength,
891 }
892 logs.AccessLog(record, app.Cfg.Log.AccessLogsFormat)
893}
894
895// PrintTree prints all registered routers.
896func (app *HttpServer) PrintTree() M {

Callers 1

LogAccessFunction · 0.80

Calls 4

AccessLogFunction · 0.92
FilterMethod · 0.65
GetMethod · 0.65
IPMethod · 0.45

Tested by

no test coverage detected