func()

in hugegraph-client-go/hgtransport/logger.go [74:97]


func (l *TextLogger) LogRoundTrip(req *http.Request, res *http.Response, err error, start time.Time, dur time.Duration) error {
    fmt.Fprintf(l.Output, "%s %s %s [status:%d request:%s]\n",
        start.Format(time.RFC3339),
        req.Method,
        req.URL.String(),
        resStatusCode(res),
        dur.Truncate(time.Millisecond),
    )
    if l.RequestBodyEnabled() && req != nil && req.Body != nil && req.Body != http.NoBody {
        var buf bytes.Buffer
        buf.ReadFrom(req.Body)
        logBodyAsText(l.Output, &buf, ">")
    }
    if l.ResponseBodyEnabled() && res != nil && res.Body != nil && res.Body != http.NoBody {
        defer res.Body.Close()
        var buf bytes.Buffer
        buf.ReadFrom(res.Body)
        logBodyAsText(l.Output, &buf, "<")
    }
    if err != nil {
        fmt.Fprintf(l.Output, "! ERROR: %v\n", err)
    }
    return nil
}