Skip to content

Commit

Permalink
Replace logrus with zap logger (#322)
Browse files Browse the repository at this point in the history
Signed-off-by: Arrobo, Gabriel <gabriel.arrobo@intel.com>
  • Loading branch information
gab-arrobo authored Oct 3, 2024
1 parent 3efe680 commit 60a71b6
Show file tree
Hide file tree
Showing 49 changed files with 516 additions and 577 deletions.
20 changes: 0 additions & 20 deletions .fossa.yml

This file was deleted.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.4-dev
1.6.0
9 changes: 4 additions & 5 deletions callback/api_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package callback

import (
"log"
"net/http"

"github.com/gin-gonic/gin"
Expand All @@ -38,14 +37,14 @@ func HTTPSmPolicyUpdateNotification(c *gin.Context) {

err := openapi.Deserialize(&request, reqBody, c.ContentType())
if err != nil {
logger.PduSessLog.Errorln("Deserialize request failed")
logger.PduSessLog.Errorln("deserialize request failed")
}

reqWrapper := httpwrapper.NewRequest(c.Request, request)
reqWrapper.Params["smContextRef"] = c.Params.ByName("smContextRef")

smContextRef := reqWrapper.Params["smContextRef"]
log.Printf("HTTPSmPolicyUpdateNotification received for UUID = %v", smContextRef)
logger.PduSessLog.Infof("HTTPSmPolicyUpdateNotification received for UUID = %v", smContextRef)

txn := transaction.NewTransaction(reqWrapper.Body.(models.SmPolicyNotification), nil, svcmsgtypes.SmfMsgType(svcmsgtypes.SmPolicyUpdateNotification))
txn.CtxtKey = smContextRef
Expand All @@ -60,7 +59,7 @@ func HTTPSmPolicyUpdateNotification(c *gin.Context) {

resBody, err := openapi.Serialize(HTTPResponse.Body, "application/json")
if err != nil {
log.Println(err)
logger.PduSessLog.Errorln(err)
}
c.Writer.Write(resBody)
c.Status(HTTPResponse.Status)
Expand All @@ -71,7 +70,7 @@ func SmPolicyControlTerminationRequestNotification(c *gin.Context) {
}

func N1N2FailureNotification(c *gin.Context) {
logger.PduSessLog.Info("Receive N1N2 Failure Notification")
logger.PduSessLog.Info("receive N1N2 Failure Notification")
stats.IncrementN11MsgStats(smf_context.SMF_Self().NfInstanceID, string(svcmsgtypes.N1N2MessageTransferFailureNotification), "In", "", "")

var request models.N1N2MsgTxfrFailureNotification
Expand Down
2 changes: 1 addition & 1 deletion callback/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Routes []Route

// NewRouter returns a new router.
func NewRouter() *gin.Engine {
router := utilLogger.NewGinWithLogrus(logger.GinLog)
router := utilLogger.NewGinWithZap(logger.GinLog)
AddService(router)
return router
}
Expand Down
21 changes: 10 additions & 11 deletions consumer/nnrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func SendNFRegistration() (*models.NfProfile, error) {
sNssais := []models.Snssai{}

if len(*smf_context.SmfInfo.SNssaiSmfInfoList) == 0 {
logger.ConsumerLog.Errorf("slice info not available, dropping NRF registration")
logger.ConsumerLog.Errorln("slice info not available, dropping NRF registration")
return &rep, fmt.Errorf("slice info nil")
}

Expand Down Expand Up @@ -92,7 +92,6 @@ func SendNFRegistration() (*models.NfProfile, error) {
logger.ConsumerLog.Infof("NRF Registration success, status [%v]", http.StatusText(res.StatusCode))
} else {
logger.ConsumerLog.Infof("handler returned wrong status code %d", status)
// fmt.Errorf("NRF return wrong status code %d", status)
logger.ConsumerLog.Errorf("NRF Registration failure, status [%v]", http.StatusText(res.StatusCode))
return &rep, fmt.Errorf("NRF Registration failure, [%v]", http.StatusText(res.StatusCode))
}
Expand All @@ -105,7 +104,7 @@ func ReSendNFRegistration() (profile *models.NfProfile) {
for {
var err error
if profile, err = SendNFRegistration(); err != nil {
logger.ConsumerLog.Warnf("Send NFRegistration Failed, %v", err)
logger.ConsumerLog.Warnf("send NFRegistration Failed, %v", err)
time.Sleep(time.Second * 2)
continue
}
Expand All @@ -114,7 +113,7 @@ func ReSendNFRegistration() (profile *models.NfProfile) {
}

var SendUpdateNFInstance = func(patchItem []models.PatchItem) (nfProfile *models.NfProfile, problemDetails *models.ProblemDetails, err error) {
logger.ConsumerLog.Debugf("Send Update NFInstance")
logger.ConsumerLog.Debugln("send Update NFInstance")

smfSelf := smf_context.SMF_Self()
configuration := Nnrf_NFManagement.NewConfiguration()
Expand Down Expand Up @@ -164,7 +163,7 @@ func SendNFDeregistration() error {
if res != nil {
metrics.IncrementSvcNrfMsgStats(smf_context.SMF_Self().NfInstanceID, string(svcmsgtypes.NnrfNFRegister), "In", http.StatusText(res.StatusCode), "")
if status := res.StatusCode; status != http.StatusNoContent {
logger.ConsumerLog.Warnln("handler returned wrong status code ", status)
logger.ConsumerLog.Warnln("handler returned wrong status code", status)
return openapi.ReportError("handler returned wrong status code %d", status)
}
}
Expand Down Expand Up @@ -216,7 +215,7 @@ func SendNrfForNfInstance(nrfUri string, targetNfType, requestNfType models.NfTy
}
}()

logger.ConsumerLog.Warnln("handler returned wrong status code ", httpResp.Status)
logger.ConsumerLog.Warnln("handler returned wrong status code", httpResp.Status)
if httpResp.Status != localErr.Error() {
metrics.IncrementSvcNrfMsgStats(smf_context.SMF_Self().NfInstanceID, string(svcMsgType), "In", http.StatusText(httpResp.StatusCode), httpResp.Status)
} else {
Expand All @@ -243,7 +242,7 @@ func SendNrfForNfInstance(nrfUri string, targetNfType, requestNfType models.NfTy
if problemDetails != nil {
logger.ConsumerLog.Errorf("SendCreateSubscription to NRF, Problem[%+v]", problemDetails)
} else if err != nil {
logger.ConsumerLog.Errorf("SendCreateSubscription Error[%+v]", err)
logger.ConsumerLog.Errorf("SendCreateSubscription error[%+v]", err)
}
smfSelf.NfStatusSubscriptions.Store(nfProfile.NfInstanceId, nrfSubData.SubscriptionId)
}
Expand Down Expand Up @@ -302,7 +301,7 @@ func SendNFDiscoveryPCF() (problemDetails *models.ProblemDetails, err error) {
}

if localErr == nil {
logger.ConsumerLog.Traceln(result.NfInstances)
logger.ConsumerLog.Debugln(result.NfInstances)
} else {
apiError, ok := localErr.(openapi.GenericOpenAPIError)
if ok {
Expand Down Expand Up @@ -349,7 +348,7 @@ func SendNFDiscoveryServingAMF(smContext *smf_context.SMContext) (*models.Proble
}

func SendDeregisterNFInstance() (*models.ProblemDetails, error) {
logger.ConsumerLog.Infof("Send Deregister NFInstance")
logger.ConsumerLog.Infof("send deregister NFInstance")

smfSelf := smf_context.SMF_Self()
// Set client and set url
Expand Down Expand Up @@ -382,7 +381,7 @@ func SendDeregisterNFInstance() (*models.ProblemDetails, error) {
}

func SendCreateSubscription(nrfUri string, nrfSubscriptionData models.NrfSubscriptionData, targetNfType models.NfType) (nrfSubData models.NrfSubscriptionData, problemDetails *models.ProblemDetails, err error) {
logger.ConsumerLog.Debugf("Send Create Subscription for %v", targetNfType)
logger.ConsumerLog.Debugf("send Create Subscription for %v", targetNfType)

var res *http.Response
nrfSubData, res, err = smf_context.SMF_Self().NFManagementClient.SubscriptionsCollectionApi.CreateSubscription(context.TODO(), nrfSubscriptionData)
Expand All @@ -407,7 +406,7 @@ func SendCreateSubscription(nrfUri string, nrfSubscriptionData models.NrfSubscri
}

func SendRemoveSubscriptionProcedure(notificationData models.NotificationData) {
logger.ConsumerLog.Infof("[SMF] Send Remove Subscription Procedure")
logger.ConsumerLog.Infoln("[SMF] Send Remove Subscription Procedure")
nfInstanceId := notificationData.NfInstanceUri[strings.LastIndex(notificationData.NfInstanceUri, "/")+1:]

if subscriptionId, ok := smf_context.SMF_Self().NfStatusSubscriptions.Load(nfInstanceId); ok {
Expand Down
4 changes: 2 additions & 2 deletions consumer/nsmf_pdusession_callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func SendSMContextStatusNotification(uri string) (*models.ProblemDetails, error)
return nil, openapi.ReportError("Send SMContextStatus Notification Failed")
}

logger.PduSessLog.Tracef("Send SMContextStatus Notification Success")
logger.PduSessLog.Debugln("send SMContextStatus Notification Success")
} else if httpResp != nil {
defer func() {
if resCloseErr := httpResp.Body.Close(); resCloseErr != nil {
Expand All @@ -47,7 +47,7 @@ func SendSMContextStatusNotification(uri string) (*models.ProblemDetails, error)
problem := localErr.(openapi.GenericOpenAPIError).Model().(models.ProblemDetails)
return &problem, nil
} else {
logger.PduSessLog.Warnln("Http Response is nil in comsumer API SMContextNotification")
logger.PduSessLog.Warnln("http response is nil in comsumer API SMContextNotification")
return nil, openapi.ReportError("Send SMContextStatus Notification Failed[%s]", localErr.Error())
}
}
Expand Down
Loading

0 comments on commit 60a71b6

Please sign in to comment.