本文整理汇总了Golang中github.com/uniqush/log.Logger.Infof方法的典型用法代码示例。如果您正苦于以下问题:Golang Logger.Infof方法的具体用法?Golang Logger.Infof怎么用?Golang Logger.Infof使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/uniqush/log.Logger
的用法示例。
在下文中一共展示了Logger.Infof方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: changeSubscription
func (self *RestAPI) changeSubscription(kv map[string]string, logger log.Logger, remoteAddr string, issub bool) {
dp, err := self.psm.BuildDeliveryPointFromMap(kv)
if err != nil {
logger.Errorf("Cannot build delivery point: %v", err)
return
}
service, err := getServiceFromMap(kv, true)
if err != nil {
logger.Errorf("From=%v Cannot get service name: %v; %v", remoteAddr, service, err)
return
}
subs, err := getSubscribersFromMap(kv, true)
if err != nil {
logger.Errorf("From=%v Service=%v Cannot get subscriber: %v", remoteAddr, service, err)
return
}
var psp *PushServiceProvider
if issub {
psp, err = self.backend.Subscribe(service, subs[0], dp)
} else {
err = self.backend.Unsubscribe(service, subs[0], dp)
}
if err != nil {
logger.Errorf("From=%v Failed: %v", remoteAddr, err)
return
}
if psp == nil {
logger.Infof("From=%v Service=%v Subscriber=%v DeliveryPoint=%v Success!", remoteAddr, service, subs[0], dp.Name())
} else {
logger.Infof("From=%v Service=%v Subscriber=%v PushServiceProvider=%v DeliveryPoint=%v Success!", remoteAddr, service, subs[0], psp.Name(), dp.Name())
}
}
示例2: pushNotification
func (self *RestAPI) pushNotification(reqId string, kv map[string]string, perdp map[string][]string, logger log.Logger, remoteAddr string, handler ApiResponseHandler) {
service, err := getServiceFromMap(kv, true)
if err != nil {
logger.Errorf("RequestId=%v From=%v Cannot get service name: %v; %v", reqId, remoteAddr, service, err)
handler.AddDetailsToHandler(ApiResponseDetails{RequestId: &reqId, From: &remoteAddr, Service: &service, Code: UNIQUSH_ERROR_CANNOT_GET_SERVICE})
return
}
subs, err := getSubscribersFromMap(kv, false)
if err != nil {
logger.Errorf("RequestId=%v From=%v Service=%v Cannot get subscriber: %v", reqId, remoteAddr, service, err)
handler.AddDetailsToHandler(ApiResponseDetails{RequestId: &reqId, From: &remoteAddr, Service: &service, Code: UNIQUSH_ERROR_CANNOT_GET_SUBSCRIBER})
return
}
if len(subs) == 0 {
logger.Errorf("RequestId=%v From=%v Service=%v NoSubscriber", reqId, remoteAddr, service)
handler.AddDetailsToHandler(ApiResponseDetails{RequestId: &reqId, From: &remoteAddr, Service: &service, Code: UNIQUSH_ERROR_NO_SUBSCRIBER})
return
}
notif, details, err := self.buildNotificationFromKV(reqId, kv, logger, remoteAddr, service, subs)
if err != nil {
handler.AddDetailsToHandler(*details)
return
}
logger.Infof("RequestId=%v From=%v Service=%v NrSubscribers=%v Subscribers=\"%+v\"", reqId, remoteAddr, service, len(subs), subs)
self.backend.Push(reqId, remoteAddr, service, subs, notif, perdp, logger, handler)
}
示例3: pushNotification
func (self *RestAPI) pushNotification(reqId string, kv map[string]string, perdp map[string][]string, logger log.Logger, remoteAddr string) {
service, err := getServiceFromMap(kv, true)
if err != nil {
logger.Errorf("RequestId=%v From=%v Cannot get service name: %v; %v", reqId, remoteAddr, service, err)
return
}
subs, err := getSubscribersFromMap(kv, false)
if err != nil {
logger.Errorf("RequestId=%v From=%v Service=%v Cannot get subscriber: %v", reqId, remoteAddr, service, err)
return
}
if len(subs) == 0 {
logger.Errorf("RequestId=%v From=%v Service=%v NoSubscriber", reqId, remoteAddr, service)
return
}
notif := NewEmptyNotification()
for k, v := range kv {
if len(v) <= 0 {
continue
}
switch k {
case "subscriber":
case "subscribers":
case "service":
// three keys need to be ignored
case "badge":
if v != "" {
var e error
_, e = strconv.Atoi(v)
if e == nil {
notif.Data["badge"] = v
} else {
notif.Data["badge"] = "0"
}
}
default:
notif.Data[k] = v
}
}
if notif.IsEmpty() {
logger.Errorf("RequestId=%v From=%v Service=%v EmptyNotification", reqId, remoteAddr, service)
return
}
logger.Infof("RequestId=%v From=%v Service=%v Subscribers=\"%v\"", reqId, remoteAddr, service, subs)
self.backend.Push(reqId, service, subs, notif, perdp, logger)
return
}
示例4: changePushServiceProvider
func (self *RestAPI) changePushServiceProvider(kv map[string]string, logger log.Logger, remoteAddr string, add bool) {
psp, err := self.psm.BuildPushServiceProviderFromMap(kv)
if err != nil {
logger.Errorf("From=%v Cannot build push service provider: %v", remoteAddr, err)
return
}
service, err := getServiceFromMap(kv, true)
if err != nil {
logger.Errorf("From=%v Cannot get service name: %v; %v", remoteAddr, service, err)
return
}
if add {
err = self.backend.AddPushServiceProvider(service, psp)
} else {
err = self.backend.RemovePushServiceProvider(service, psp)
}
if err != nil {
logger.Errorf("From=%v Failed: %v", remoteAddr, err)
return
}
logger.Infof("From=%v Service=%v PushServiceProvider=%v Success!", remoteAddr, service, psp.Name())
return
}
示例5: changeSubscription
func (self *RestAPI) changeSubscription(kv map[string]string, logger log.Logger, remoteAddr string, issub bool) ApiResponseDetails {
dp, err := self.psm.BuildDeliveryPointFromMap(kv)
if err != nil {
logger.Errorf("Cannot build delivery point: %v", err)
return ApiResponseDetails{From: &remoteAddr, Code: UNIQUSH_ERROR_BUILD_DELIVERY_POINT, ErrorMsg: strPtrOfErr(err)}
}
service, err := getServiceFromMap(kv, true)
if err != nil {
logger.Errorf("From=%v Cannot get service name: %v; %v", remoteAddr, service, err)
return ApiResponseDetails{From: &remoteAddr, Service: &service, Code: UNIQUSH_ERROR_CANNOT_GET_SERVICE, ErrorMsg: strPtrOfErr(err)}
}
subs, err := getSubscribersFromMap(kv, true)
if err != nil {
logger.Errorf("From=%v Service=%v Cannot get subscriber: %v", remoteAddr, service, err)
return ApiResponseDetails{From: &remoteAddr, Service: &service, Code: UNIQUSH_ERROR_CANNOT_GET_SUBSCRIBER, ErrorMsg: strPtrOfErr(err)}
}
var psp *push.PushServiceProvider
if issub {
psp, err = self.backend.Subscribe(service, subs[0], dp)
} else {
err = self.backend.Unsubscribe(service, subs[0], dp)
}
if err != nil {
logger.Errorf("From=%v Failed: %v", remoteAddr, err)
return ApiResponseDetails{From: &remoteAddr, Code: UNIQUSH_ERROR_GENERIC, ErrorMsg: strPtrOfErr(err)}
}
dpName := dp.Name()
if psp == nil {
logger.Infof("From=%v Service=%v Subscriber=%v DeliveryPoint=%v Success!", remoteAddr, service, subs[0], dpName)
return ApiResponseDetails{From: &remoteAddr, Service: &service, Subscriber: &subs[0], DeliveryPoint: &dpName, Code: UNIQUSH_SUCCESS}
} else {
pspName := psp.Name()
logger.Infof("From=%v Service=%v Subscriber=%v PushServiceProvider=%v DeliveryPoint=%v Success!", remoteAddr, service, subs[0], pspName, dpName)
return ApiResponseDetails{From: &remoteAddr, Service: &service, Subscriber: &subs[0], DeliveryPoint: &dpName, PushServiceProvider: &pspName, Code: UNIQUSH_SUCCESS}
}
}
示例6: changePushServiceProvider
func (self *RestAPI) changePushServiceProvider(kv map[string]string, logger log.Logger, remoteAddr string, add bool) ApiResponseDetails {
psp, err := self.psm.BuildPushServiceProviderFromMap(kv)
if err != nil {
logger.Errorf("From=%v Cannot build push service provider: %v", remoteAddr, err)
return ApiResponseDetails{From: &remoteAddr, Code: UNIQUSH_ERROR_BUILD_PUSH_SERVICE_PROVIDER, ErrorMsg: strPtrOfErr(err)}
}
service, err := getServiceFromMap(kv, true)
if err != nil {
logger.Errorf("From=%v Cannot get service name: %v; %v", remoteAddr, service, err)
return ApiResponseDetails{From: &remoteAddr, Service: &service, Code: UNIQUSH_ERROR_CANNOT_GET_SERVICE, ErrorMsg: strPtrOfErr(err)}
}
if add {
err = self.backend.AddPushServiceProvider(service, psp)
} else {
err = self.backend.RemovePushServiceProvider(service, psp)
}
if err != nil {
logger.Errorf("From=%v Failed: %v", remoteAddr, err)
return ApiResponseDetails{From: &remoteAddr, Code: UNIQUSH_ERROR_GENERIC, ErrorMsg: strPtrOfErr(err)}
}
pspName := psp.Name()
logger.Infof("From=%v Service=%v PushServiceProvider=%v Success!", remoteAddr, service, pspName)
return ApiResponseDetails{From: &remoteAddr, Service: &service, PushServiceProvider: &pspName, Code: UNIQUSH_SUCCESS}
}