mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-10-31 22:18:52 +00:00
expose the embedded log fields in httpclient.Request{}
This commit is contained in:
parent
f17ef91fb9
commit
4811ded078
3 changed files with 8 additions and 6 deletions
|
@ -264,12 +264,12 @@ func (c *Client) DoOnce(r *Request) (rsp *http.Response, retry bool, err error)
|
|||
|
||||
if rsp != nil {
|
||||
// Log successful rsp.
|
||||
r.log.Info(rsp.Status)
|
||||
r.Entry.Info(rsp.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// Log any errors.
|
||||
r.log.Error(err)
|
||||
r.Entry.Error(err)
|
||||
|
||||
switch {
|
||||
case !retry:
|
||||
|
|
|
@ -32,9 +32,6 @@ const (
|
|||
// Request wraps an HTTP request
|
||||
// to add our own retry / backoff.
|
||||
type Request struct {
|
||||
// log entry fields.
|
||||
log log.Entry
|
||||
|
||||
// Current backoff dur.
|
||||
backoff time.Duration
|
||||
|
||||
|
@ -46,6 +43,9 @@ type Request struct {
|
|||
// be attempted.
|
||||
done bool
|
||||
|
||||
// log fields.
|
||||
log.Entry
|
||||
|
||||
// underlying request.
|
||||
*http.Request
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ type Request struct {
|
|||
func WrapRequest(r *http.Request) Request {
|
||||
var rr Request
|
||||
rr.Request = r
|
||||
rr.log = log.WithContext(r.Context()).
|
||||
rr.Entry = log.WithContext(r.Context()).
|
||||
WithField("method", r.Method).
|
||||
WithField("url", r.URL.String()).
|
||||
WithField("contentType", r.Header.Get("Content-Type"))
|
||||
|
|
|
@ -79,6 +79,7 @@ func (t *transport) BatchDeliver(ctx context.Context, obj map[string]interface{}
|
|||
reqs = append(reqs, req)
|
||||
}
|
||||
|
||||
// Push prepared request list to the delivery queue.
|
||||
t.controller.state.Workers.Delivery.Queue.Push(reqs...)
|
||||
|
||||
// Return combined err.
|
||||
|
@ -109,6 +110,7 @@ func (t *transport) Deliver(ctx context.Context, obj map[string]interface{}, to
|
|||
return err
|
||||
}
|
||||
|
||||
// Push prepared request to the delivery queue.
|
||||
t.controller.state.Workers.Delivery.Queue.Push(req)
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue