From 81e4392fe9d7479d5f5599a3e799153f6608868e Mon Sep 17 00:00:00 2001 From: Wan Yue Chen Date: Wed, 20 Sep 2023 18:20:23 +0800 Subject: [PATCH] fix genlog in getcpcprops (#99) --- pkg/zhmcclient/cpc.go | 22 +++++++++++----------- sample.go | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/zhmcclient/cpc.go b/pkg/zhmcclient/cpc.go index 6e71a61..12c40eb 100644 --- a/pkg/zhmcclient/cpc.go +++ b/pkg/zhmcclient/cpc.go @@ -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 } @@ -111,9 +111,9 @@ 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)) @@ -121,9 +121,9 @@ func (m *CpcManager) GetCPCProperties(cpcURI string) (*CPCProperties, int, *HmcE } 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 } diff --git a/sample.go b/sample.go index 3090b35..f2c6655 100644 --- a/sample.go +++ b/sample.go @@ -26,8 +26,8 @@ import ( ) func NewZapLogger() zhmcclient.Logger { - zapLogger, _ := zap.NewProduction() - return zapLogger + zapLogger, _ := zap.NewProduction() + return zapLogger } var logger = NewZapLogger() @@ -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 **************")