Add trace log with successful HTTP response data
This commit is contained in:
parent
52a703c94d
commit
75468e87d8
1 changed files with 11 additions and 0 deletions
|
@ -97,5 +97,16 @@ func typedHTTPResponse[T proto.Message](resp *http.Response, err error) (parsed
|
||||||
}
|
}
|
||||||
parsed = parsed.ProtoReflect().New().Interface().(T)
|
parsed = parsed.ProtoReflect().New().Interface().(T)
|
||||||
retErr = decodeProtoResp(body, resp.Header.Get("Content-Type"), parsed)
|
retErr = decodeProtoResp(body, resp.Header.Get("Content-Type"), parsed)
|
||||||
|
successEvt := zerolog.Ctx(resp.Request.Context()).Trace()
|
||||||
|
if successEvt.Enabled() {
|
||||||
|
successEvt.
|
||||||
|
Int("status_code", resp.StatusCode).
|
||||||
|
Str("url", resp.Request.URL.String()).
|
||||||
|
Str("response_body", base64.StdEncoding.EncodeToString(body)).
|
||||||
|
Bool("parsed_has_unknown_fields", len(parsed.ProtoReflect().GetUnknown()) > 0).
|
||||||
|
Type("parsed_data_type", parsed).
|
||||||
|
Any("parsed_data", parsed).
|
||||||
|
Msg("HTTP request to Google Messages succeeded")
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue