Skip to content

Commit

Permalink
fix genlog in getcpcprops (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
CaryChencn authored and GitHub Enterprise committed Sep 20, 2023
1 parent 2ee1229 commit 81e4392
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
22 changes: 11 additions & 11 deletions pkg/zhmcclient/cpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ func (m *CpcManager) GetCPCProperties(cpcURI string) (*CPCProperties, int, *HmcE
status, responseBody, err := m.client.ExecuteRequest(http.MethodGet, requestUrl, nil, "")
if err != nil {
logger.Error("error on getting cpc properties",
genlog.String("request url", fmt.Sprint(requestUrl)),
genlog.String("method", http.MethodGet),
genlog.String("status", fmt.Sprint(status)),
genlog.Error(fmt.Errorf("%v", err)))
zap.String("request url", fmt.Sprint(requestUrl)),
zap.String("method", http.MethodGet),
zap.String("status", fmt.Sprint(status)),
zap.Error(fmt.Errorf("%v", err)))
return nil, status, err
}

Expand All @@ -111,19 +111,19 @@ func (m *CpcManager) GetCPCProperties(cpcURI string) (*CPCProperties, int, *HmcE
err := json.Unmarshal(responseBody, cpcProps)
if err != nil {
logger.Error("error on unmarshalling cpcs",
genlog.String("request url", fmt.Sprint(requestUrl)),
genlog.String("method", http.MethodGet),
genlog.Error(fmt.Errorf("%v", getHmcErrorFromErr(ERR_CODE_HMC_UNMARSHAL_FAIL, err))))
zap.String("request url", fmt.Sprint(requestUrl)),
zap.String("method", http.MethodGet),
zap.Error(fmt.Errorf("%v", getHmcErrorFromErr(ERR_CODE_HMC_UNMARSHAL_FAIL, err))))
return nil, status, getHmcErrorFromErr(ERR_CODE_HMC_UNMARSHAL_FAIL, err)
}
logger.Info(fmt.Sprintf("Response: request url: %v, method: %v, status: %v, cpcs: %v", requestUrl, http.MethodGet, status, cpcProps))
return cpcProps, status, nil
}
errorResponseBody := GenerateErrorFromResponse(responseBody)
logger.Error("error getting cpc properties",
genlog.String("request url", fmt.Sprint(requestUrl)),
genlog.String("method", http.MethodGet),
genlog.String("status: ", fmt.Sprint(status)),
genlog.Error(fmt.Errorf("%v", errorResponseBody)))
zap.String("request url", fmt.Sprint(requestUrl)),
zap.String("method", http.MethodGet),
zap.String("status: ", fmt.Sprint(status)),
zap.Error(fmt.Errorf("%v", errorResponseBody)))
return nil, status, errorResponseBody
}
6 changes: 3 additions & 3 deletions sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
)

func NewZapLogger() zhmcclient.Logger {
zapLogger, _ := zap.NewProduction()
return zapLogger
zapLogger, _ := zap.NewProduction()
return zapLogger
}

var logger = NewZapLogger()
Expand Down Expand Up @@ -314,7 +314,7 @@ func GetCPCProps(hmcManager zhmcclient.ZhmcAPI) {
cpcURI := GetCPCURI(hmcManager)
cpc, _, err := hmcManager.GetCPCProperties(cpcURI)
if err != nil {
logger.Fatal("", genlog.Any("Get CPC properties error", err))
logger.Fatal("", zap.Any("Get CPC properties error", err))
}
logger.Info("Get properties operation successfull")
logger.Info("********* CPC properties **************")
Expand Down

0 comments on commit 81e4392

Please sign in to comment.