Logging improvement for VGC-ONOS-NBI
Change-Id: I901964b71f2509cc81c44a208e5f5c563efd9704
diff --git a/voltha-go-controller/onos_nbi/flowadapter.go b/voltha-go-controller/onos_nbi/flowadapter.go
index b31700d..232b457 100644
--- a/voltha-go-controller/onos_nbi/flowadapter.go
+++ b/voltha-go-controller/onos_nbi/flowadapter.go
@@ -109,14 +109,19 @@
vars := mux.Vars(r)
deviceID := vars["deviceId"]
flowIDStr := vars["flowId"]
- logger.Debugw(ctx, "Received Get Flows specific to flowID and deviceID", log.Fields{"flowId": flowIDStr, "DeviceID": deviceID})
+ var flowID uint64
+ var parseErr error
- flowID, parseErr := strconv.ParseUint(flowIDStr, 10, 64)
- if parseErr != nil {
- logger.Errorw(ctx, "Failed to parse flowIDStr from string to uint64", log.Fields{"flowIDStr": flowIDStr, "Reason": parseErr.Error()})
- w.WriteHeader(http.StatusInternalServerError)
- return
+ logger.Debugw(ctx, "Received Get Flows specific to flowID and deviceID", log.Fields{"flowId": flowIDStr, "DeviceID": deviceID})
+ if len(flowIDStr) > 0 {
+ flowID, parseErr = strconv.ParseUint(flowIDStr, 10, 64)
+ if parseErr != nil {
+ logger.Errorw(ctx, "Failed to parse flowIDStr from string to uint64", log.Fields{"flowIDStr": flowIDStr, "Reason": parseErr.Error()})
+ w.WriteHeader(http.StatusInternalServerError)
+ return
+ }
}
+
var flowResp FlowEntry
if len(deviceID) > 0 && len(flowIDStr) > 0 {
flow, err := fh.getFlow(deviceID, flowID)