Skip to content

Commit f64f644

Browse files
chore: add debug logging for updater (#1353)
Signed-off-by: Darren Murray <[email protected]>
1 parent 06b851a commit f64f644

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lwupdater/updater.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"time"
3131

3232
"github.com/cenkalti/backoff/v4"
33+
"github.com/lacework/go-sdk/lwlogger"
3334
"github.com/pkg/errors"
3435
)
3536

@@ -43,6 +44,8 @@ const (
4344
DisableEnv = "LW_UPDATES_DISABLE"
4445
)
4546

47+
var log = lwlogger.New("")
48+
4649
// Version is used to check project versions and store it into a cache file
4750
// normally at the directory `~/.config/lacework`, to execute regular version checks
4851
type Version struct {
@@ -155,6 +158,7 @@ func getGitRelease(project, version string) (*gitReleaseResponse, error) {
155158
return err
156159
}
157160
if resp.StatusCode < 200 || resp.StatusCode > 299 {
161+
logHeaders(resp)
158162
return errors.New(resp.Status)
159163
}
160164
return nil
@@ -178,6 +182,14 @@ func backoffStrategy() *backoff.ExponentialBackOff {
178182
return strategy
179183
}
180184

185+
func logHeaders(resp *http.Response) {
186+
var headers strings.Builder
187+
for key, values := range resp.Header {
188+
headers.WriteString(fmt.Sprintf("%s: %s\n", key, strings.Join(values, ",")))
189+
}
190+
log.Debug(headers.String())
191+
}
192+
181193
type gitReleaseResponse struct {
182194
ID int32 `json:"id"`
183195
Url string `json:"url"`

0 commit comments

Comments
 (0)