Skip to content

Commit 1c99115

Browse files
committed
refactor: minor changes to debug messages
Signed-off-by: David J. Allen <davidallendj@gmail.com>
1 parent 4d0782f commit 1c99115

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

cmd/send.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ var sendCmd = &cobra.Command{
7171
}
7272

7373
// show the data that was just loaded as input
74-
log.Debug().Any("input", inputData).Send()
74+
// inputRaw, _ := json.MarshalIndent(inputData, "", " ")
75+
log.Debug().Int("endpoint_count", len(inputData)).Send()
7576

7677
for _, host := range args {
7778
var (
@@ -83,6 +84,7 @@ var sendCmd = &cobra.Command{
8384
for _, dataObject := range inputData {
8485
// skip on to the next thing if it's does not exist
8586
if dataObject == nil {
87+
log.Warn().Str("host", host).Msg("skipping request to host")
8688
continue
8789
}
8890

@@ -93,16 +95,23 @@ var sendCmd = &cobra.Command{
9395

9496
host, err = urlx.Sanitize(host)
9597
if err != nil {
96-
log.Warn().Err(err).Str("host", host).Msg("could not sanitize host")
98+
log.Warn().
99+
Err(err).
100+
Str("host", host).
101+
Msg("could not sanitize host")
97102
}
98103

99104
// convert to JSON to send data
100105
body, err = json.MarshalIndent(dataObject, "", " ")
101106
if err != nil {
102-
log.Error().Err(err).Msg("failed to marshal request data")
107+
log.Error().
108+
Err(err).
109+
Msg("failed to marshal request data")
103110
continue
104111
}
112+
log.Debug().Str("host", host).RawJSON("data", body).Send()
105113

114+
// make request to remote host
106115
err = smdClient.Add(body, headers)
107116
if err != nil {
108117
// try updating instead
@@ -112,12 +121,16 @@ var sendCmd = &cobra.Command{
112121
if err != nil {
113122
log.Error().
114123
Err(err).
115-
Msgf("failed to forcibly update Redfish endpoint with ID %s", smdClient.Xname)
124+
Str("host", host).
125+
Str("ID", smdClient.Xname).
126+
Msgf("failed to forcibly update Redfish endpoint")
116127
}
117128
} else {
118129
log.Error().
119130
Err(err).
120-
Msgf("failed to add Redfish endpoint with ID %s", smdClient.Xname)
131+
Str("host", host).
132+
Str("ID", smdClient.Xname).
133+
Msgf("failed to add Redfish endpoint")
121134
}
122135
}
123136
}

pkg/client/smd.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ func (c *SmdClient) Add(data HTTPBody, headers HTTPHeader) error {
5959
return fmt.Errorf("returned status code %d when adding endpoint", res.StatusCode)
6060
}
6161
}
62-
log.Debug().Msgf("%v (%v)\n%s\n", url, res.Status, string(body))
62+
log.Debug().
63+
Str("url", url).
64+
Str("status", res.Status).
65+
Int("status", res.StatusCode).
66+
RawJSON("body", body).
67+
Send()
6368
}
6469
return err
6570
}

0 commit comments

Comments
 (0)