Skip to content

Commit b0c039f

Browse files
jentingroboquat
authored andcommitted
ws-manager: log JSON as an object instead of a string
Signed-off-by: JenTing Hsiao <[email protected]>
1 parent e363984 commit b0c039f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

components/ws-manager/pkg/manager/manager.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ func (m *Manager) StartWorkspace(ctx context.Context, req *api.StartWorkspaceReq
206206
clog.Info("StartWorkspace")
207207
reqs, _ := protojson.Marshal(req)
208208
safeReqs, _ := log.RedactJSON(reqs)
209-
clog.WithField("req", string(safeReqs)).Debug("StartWorkspace request received")
209+
safeReqsLog := make(map[string]interface{})
210+
_ = json.Unmarshal(safeReqs, &safeReqsLog)
211+
clog.WithFields(safeReqsLog).Debug("StartWorkspace request received")
210212

211213
// Make sure the objects we're about to create do not exist already
212214
switch req.Type {
@@ -1386,12 +1388,16 @@ func (m *Manager) onChange(ctx context.Context, status *api.WorkspaceStatus) {
13861388
if status.Conditions.Failed != "" {
13871389
status, _ := protojson.Marshal(status)
13881390
safeStatus, _ := log.RedactJSON(status)
1389-
clog.WithField("status", string(safeStatus)).Error("workspace failed")
1391+
safeStatusLog := make(map[string]interface{})
1392+
_ = json.Unmarshal(safeStatus, &safeStatusLog)
1393+
clog.WithFields(safeStatusLog).Error("workspace failed")
13901394
}
13911395
if status.Phase == 0 {
13921396
status, _ := protojson.Marshal(status)
13931397
safeStatus, _ := log.RedactJSON(status)
1394-
clog.WithField("status", string(safeStatus)).Error("workspace in UNKNOWN phase")
1398+
safeStatusLog := make(map[string]interface{})
1399+
_ = json.Unmarshal(safeStatus, &safeStatusLog)
1400+
clog.WithFields(safeStatusLog).Error("workspace in UNKNOWN phase")
13951401
}
13961402
}
13971403

0 commit comments

Comments
 (0)