Ejemplo n.º 1
0
func newSyslogAdapter(w *syslog.Writer) *LoggingAdapter {
	return &LoggingAdapter{
		Debugf: func(format string, v ...interface{}) { w.Debug(fmt.Sprintf(format, v...)) },
		Infof:  func(format string, v ...interface{}) { w.Info(fmt.Sprintf(format, v...)) },
		Warnf:  func(format string, v ...interface{}) { w.Warning(fmt.Sprintf(format, v...)) },
		Errorf: func(format string, v ...interface{}) { w.Err(fmt.Sprintf(format, v...)) },
		Fatalf: func(format string, v ...interface{}) {
			s := fmt.Sprintf(format, v...)

			w.Crit(s)

			os.Exit(1)
		},
		Panicf: func(format string, v ...interface{}) {
			s := fmt.Sprintf(format, v...)

			w.Emerg(s)

			panic(s)
		},
	}
}
Ejemplo n.º 2
0
func Gettasks(makeFlag string, quant int, golog syslog.Writer) {

	golog.Info("Start Gettasks")

	quantstr := strconv.Itoa(quant)

	if res, err := http.Get("http://latest.kannelgo.sinelgamysql.appspot.com/gettasks?makeflag=" + makeFlag + "&tasksquant=" + quantstr); err != nil {

		golog.Err(err.Error())

	} else {

		if data, err := ioutil.ReadAll(res.Body); err != nil {

			golog.Err(err.Error())

		} else {

			sliceforjson := make([]d.Smsout, 2)

			json.Unmarshal(data, &sliceforjson)

			var sendok bool
			for _, smsout := range sliceforjson {

				sendok = false
				golog.Info(smsout.Phoneto)
				golog.Info(smsout.Opcode)
				golog.Info(smsout.Nmake)

				sendok = checkaclient.CheckByPhone(smsout.Phoneto)

				if sendok {

					golog.Info("sendok OK makeFlag " + makeFlag)

					if makeFlag == "sms179019" {

						//					pr.SendSMSKannel(smsout)
						// for now elisa
						pr.SmsSendBy("elisa", smsout, golog)
						//					pr.SendSMSCgwSonera(smsout)
						//					pr.SendSMSSonera(smsout)

					} else if makeFlag == "gsm179019" {
						//					pr.SendSMSSonera(smsout)
						pr.SmsSendBy("sonera", smsout, golog)
						//					pr.SendSMSCgwSonera(smsout) //problems öä

					} else if makeFlag == "voicetr" {

						golog.Info("send by vocetr")
						pr.SmsSendBy("voicetr", smsout, golog)

					} else if makeFlag == "sms179029" {

						golog.Info("send by pullpull now DNA only")
						pr.SmsSendBy("pullpull", smsout, golog)

					}

					insertsmsins.InsertSmsRecord(smsout.Phoneto, smsout.Text, makeFlag, golog)

				} else {

					//					fmt.Println("Dont't send sms for "+smsout.Phoneto)
					golog.Warning("Dont't send sms for " + smsout.Phoneto)
				}
			}

		}
	}
}