Skip to content

Commit 5a65049

Browse files
committed
add more logging
Signed-off-by: Daniel Hawton <[email protected]>
1 parent 09156cc commit 5a65049

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

internal/v1/user/visitor.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ func postVisitor(c *gin.Context) {
100100
}
101101

102102
if location.Subdivision != user.Subdivision || location.Division != user.Division || location.Region != user.Region {
103+
log.Infof("User %d location changed: %s/%s/%s -> %s/%s/%s", user.CID, user.Region, user.Division, user.Subdivision, location.Region, location.Division, location.Subdivision)
103104
user.Region = location.Region
104105
user.Division = location.Division
105106
user.Subdivision = location.Subdivision

pkg/network/base.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"net/http"
2222
"strings"
2323

24+
"github.com/google/uuid"
2425
"moul.io/http2curl"
2526

2627
"github.com/adh-partnership/api/pkg/logger"
@@ -42,9 +43,11 @@ func Handle(method, url, contenttype, body string) (int, []byte, error) {
4243
// HandleWithHeaders will make the request as presented in a structured and expected way. It adds appropriate headers, including
4344
// a user agent so our requests can be known to come from us.
4445
func HandleWithHeaders(method, url, contenttype, body string, headers map[string]string) (int, []byte, error) {
46+
request_id, _ := uuid.NewV7()
47+
4548
r, err := http.NewRequest(method, url, strings.NewReader(body))
46-
log.Debugf("Making request: %s %s", method, url)
47-
log.Debugf("with Body: %s", body)
49+
log.Infof("Request %s - Making request: %s %s", request_id, method, url)
50+
log.Infof("Request %s - With Body: %s", request_id, body)
4851
if err != nil {
4952
return 0, nil, err
5053
}
@@ -56,7 +59,7 @@ func HandleWithHeaders(method, url, contenttype, body string, headers map[string
5659
}
5760

5861
curl, _ := http2curl.GetCurlCommand(r)
59-
log.Debugf("Request curl equivalent: %s", curl)
62+
log.Debugf("Request %s - Request curl equivalent: %s", request_id, curl)
6063

6164
client := &http.Client{}
6265
resp, err := client.Do(r)
@@ -73,8 +76,8 @@ func HandleWithHeaders(method, url, contenttype, body string, headers map[string
7376
return 0, nil, err
7477
}
7578

76-
log.Debugf("Response from %s %s: %d", method, url, resp.StatusCode)
77-
log.Tracef("Response body: %s", string(contents))
79+
log.Infof("Request %s - Response from %s %s: %d", request_id, method, url, resp.StatusCode)
80+
log.Tracef("Request %s - Response body: %s", request_id, string(contents))
7881

7982
return resp.StatusCode, contents, nil
8083
}

0 commit comments

Comments
 (0)