MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / logDuration

Method logDuration

rest/handler.go:796–824  ·  view source on GitHub ↗
(realTime bool)

Source from the content-addressed store, hash-verified

794}
795
796func (h *handler) logDuration(realTime bool) {
797 if h.loggedDuration {
798 return
799 }
800 h.loggedDuration = true
801
802 var duration time.Duration
803 if realTime {
804 duration = time.Since(h.startTime)
805 }
806
807 // Log timings/status codes for errors under the HTTP log key
808 // and the HTTPResp log key for everything else.
809 logKey := base.KeyHTTPResp
810 logLevel := base.LevelInfo
811
812 // if error status, log at HTTP/Info
813 if h.status >= 300 {
814 logKey = base.KeyHTTP
815 } else if h.httpLogLevel != nil {
816 // if the handler requested a different log level, and the request was successful, we'll honour that log level.
817 logLevel = *h.httpLogLevel
818 }
819
820 base.LogLevelCtx(h.ctx(), logLevel, logKey, "%s: --> %d %s (%.1f ms)",
821 h.formatSerialNumber(), h.status, h.statusMessage,
822 float64(duration)/float64(time.Millisecond),
823 )
824}
825
826// logRESTCount will increment the number of public REST requests stat for public REST requests excluding _blipsync requests if they are attached to a database.
827func (h *handler) logRESTCount() {

Callers 4

logStatusWithDurationMethod · 0.95
logStatusMethod · 0.95
makeHandlerWithOptionsFunction · 0.80
wrapRouterFunction · 0.80

Calls 4

ctxMethod · 0.95
formatSerialNumberMethod · 0.95
LogLevelCtxFunction · 0.92
SinceMethod · 0.45

Tested by

no test coverage detected