fix(notify): optimization of print log

1. remomve unnecessary log
2. reduce the level of some logs, such as info -> debug
This commit is contained in:
rainzm
2021-08-03 16:54:01 +08:00
parent caa15ce0f8
commit edcd98e5fe
3 changed files with 1 additions and 9 deletions
-6
View File
@@ -90,7 +90,6 @@ func (nm *SNotificationManager) ValidateCreateData(ctx context.Context, userCred
input.Contacts = []string{""}
}
}
log.Infof("notify input: %s", jsonutils.Marshal(input))
// check robot
if len(input.Robots) > 0 {
@@ -161,7 +160,6 @@ func (nm *SNotificationManager) ValidateCreateData(ctx context.Context, userCred
if err != nil {
return input, errors.Wrapf(err, "unable to generate name for %s", name)
}
log.Infof("after validatecreate input: %s", jsonutils.Marshal(input))
return input, nil
}
@@ -219,7 +217,6 @@ func (nm *SNotificationManager) AllowPerformEventNotify(ctx context.Context, use
// TODO: support project and domain
func (nm *SNotificationManager) PerformEventNotify(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.NotificationManagerEventNotifyInput) (api.NotificationManagerEventNotifyOutput, error) {
log.Infof("default receiverIds: %s", input.ReceiverIds)
var output api.NotificationManagerEventNotifyOutput
// check event
_, err := parseEvent(input.Event)
@@ -250,7 +247,6 @@ func (nm *SNotificationManager) PerformEventNotify(ctx context.Context, userCred
if err != nil {
return output, errors.Wrap(err, "unable to get receive")
}
log.Infof("receiver for topic: %s", receiverIds1)
receiverIds = append(receiverIds, receiverIds1...)
}
@@ -414,7 +410,6 @@ func (nm *SNotificationManager) createWithRobots(ctx context.Context, userCred m
func (nm *SNotificationManager) create(ctx context.Context, userCred mcclient.TokenCredential, contactType string, receiverIds, contacts []string, priority, eventId string) error {
if len(receiverIds)+len(contacts) == 0 {
log.Infof("%s: no send", contactType)
return nil
}
@@ -441,7 +436,6 @@ func (nm *SNotificationManager) create(ctx context.Context, userCred mcclient.To
return errors.Wrap(err, "ReceiverNotificationManager.CreateContact")
}
}
log.Infof("start NotificationSendTask for %s", contactType)
n.SetModelManager(nm, n)
task, err := taskman.TaskManager.NewTask(ctx, "NotificationSendTask", n, userCred, nil, "", "")
if err != nil {
-2
View File
@@ -105,7 +105,6 @@ func (sm *SSubscriberManager) validateReceivers(ctx context.Context, receivers [
}
func (sm *SSubscriberManager) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, input api.SubscriberCreateInput) (api.SubscriberCreateInput, error) {
log.Infof("before deal: %s", jsonutils.Marshal(input))
var err error
// permission check
sSystem, sDomain := string(rbacutils.ScopeSystem), string(rbacutils.ScopeDomain)
@@ -191,7 +190,6 @@ func (sm *SSubscriberManager) ValidateCreateData(ctx context.Context, userCred m
default:
return input, httperrors.NewInputParameterError("unkown type %q", input.Type)
}
log.Infof("after deal input: %s", jsonutils.Marshal(input))
return input, nil
}
+1 -1
View File
@@ -216,7 +216,7 @@ type FailedReceiverSpec struct {
}
func (self *NotificationSendTask) batchSend(ctx context.Context, contactType string, receivers []ReceiverSpec, params rpcapi.SendParams) (fails []FailedReceiverSpec, err error) {
log.Infof("contactType: %s, receivers: %s, params: %s", contactType, receivers, jsonutils.Marshal(params))
log.Debugf("contactType: %s, receivers: %s, params: %s", contactType, receivers, jsonutils.Marshal(params))
if contactType != apis.ROBOT && contactType != apis.WEBHOOK {
return self._batchSend(ctx, contactType, receivers, func(res []*rpcapi.SReceiver) ([]*rpcapi.FailedRecord, error) {
return models.NotifyService.BatchSend(ctx, contactType, rpcapi.BatchSendParams{