当前位置: 首页>>代码示例>>Golang>>正文


Golang Writer.Info方法代码示例

本文整理汇总了Golang中log/syslog.Writer.Info方法的典型用法代码示例。如果您正苦于以下问题:Golang Writer.Info方法的具体用法?Golang Writer.Info怎么用?Golang Writer.Info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在log/syslog.Writer的用法示例。


在下文中一共展示了Writer.Info方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: xmlcheck

func xmlcheck(golog syslog.Writer, provider string, phone string, data []byte) {

	//	log.Println("GetUrl:xmlcheck check provider ", provider, "phone", phone)
	//
	//	<SmsResponse>
	//        <version>1</version>
	//        <result>1</result>
	//        <resultstring>success</resultstring>
	//        <description></description>
	//        <partcount>1</partcount>
	//        <endcause></endcause>
	//</SmsResponse>

	v := Dataxml{}
	err := xml.Unmarshal(data, &v)
	if err != nil {
		//		fmt.Printf("error: %v", err)
		golog.Err(err.Error())

		blockphone(phone)

	} else {

		//		fmt.Printf("Result: %q\n", v.Result)
		golog.Info(v.Result)

	}
}
开发者ID:sinelga,项目名称:KannelGoInt,代码行数:28,代码来源:getUrl.go

示例2: configParse

func configParse(cfg *config, mainLogger *syslog.Writer) bool {
	const KEY = 0
	const VAL = 1
	file, err := os.Open(CONFIG_PATH)
	if err != nil {
		return false
	}
	defer file.Close()

	scanner := bufio.NewScanner(file)
	newConf := false
	for scanner.Scan() {
		read := scanner.Text()
		if len(read) > 0 && read[0] != '#' {
			newConf = true
			pair := strings.Split(read, "=")
			trimmedKey := strings.TrimSpace(pair[KEY])
			trimmedVal := strings.TrimSpace(pair[VAL])
			val, _ := strconv.Atoi(trimmedVal)
			configUpdate(cfg, trimmedKey, uint16(val))
			mainLogger.Info(fmt.Sprintf("Custom setting found %s: %s", trimmedKey, trimmedVal))
		}
	}

	if !newConf {
		mainLogger.Info("No custom settings found, using defaults")
	}

	if err := scanner.Err(); err != nil {
		log.Fatal("Error: could not parse config file")
	}

	return true
}
开发者ID:hspak,项目名称:simpfand-go,代码行数:34,代码来源:config_parse.go

示例3: SendSMS

func SendSMS(golog syslog.Writer, clphonenum string, text string, site string) {

	var smsout d.Smsout

	if text == "" {

		golog.Info("Send first SMS on " + clphonenum)
		smsout.Phoneto = strings.Replace(clphonenum, "358", "0", 1)
		smsout.Text = "Soita! Miia. puh. 070095943"
		smsout.Phonefrom = "070095943"
		smsout.Opcode = "notImpotent"
		smsout.Nmake = "notImpotent"

	} else {
		golog.Info("Send Second SMS on " + clphonenum + " " + text)

		smsout.Phoneto = strings.Replace(clphonenum, "358", "0", 1)
		smsout.Text = text
		smsout.Phonefrom = "070095943"
		smsout.Opcode = "notImpotent"
		smsout.Nmake = "notImpotent"

	}

	pr.SmsSendBy("sonera", smsout, golog)

}
开发者ID:sinelga,项目名称:KannelGoInt,代码行数:27,代码来源:sendsmsout.go

示例4: SmsSendBy

func SmsSendBy(provider string, smsout d.Smsout, golog syslog.Writer) {

	var urlstr string

	if provider == "elisa" {

		if Url, err := url.Parse("http://localhost:13013"); err != nil {

			panic("boom")
		} else {

			Url.Path += "/cgi-bin/sendsms"
			parameters := url.Values{}
			parameters.Add("username", "elisa")
			parameters.Add("password", "elisa")
			//		parameters.Add("charset", "ISO-8859-1")
			parameters.Add("charset", "UTF8")
			parameters.Add("to", smsout.Phoneto)
			//				parameters.Add("to", "+358504440106") //for test
			//		parameters.Add("from", smsout.Phonefrom)
			parameters.Add("text", smsout.Text)

			Url.RawQuery = parameters.Encode()
			urlstr = Url.String()

		}

	} else if provider == "sonera" {

		if Url, err := url.Parse("http://localhost:8050"); err != nil {

			panic("boom")
		} else {

			Url.Path += "/send"
			parameters := url.Values{}

			parameters.Add("to", smsout.Phoneto)

			parameters.Add("from", strings.Replace(smsout.Phonefrom, "+3587", "07", 1))
			textout := Utf8Conver(smsout.Text, "iso-8859-1")
			parameters.Add("msg", textout)

			Url.RawQuery = parameters.Encode()
			urlstr = Url.String()

		}

	} else if provider == "voicetr" {

		//		log.Println("start voicetr new 11")
		golog.Info("start voicetr")

		if Url, err := url.Parse("https://www.voicetrading.com"); err != nil {

			panic("boom")
		} else {

			Url.Path += "/myaccount/sendsms.php"
			parameters := url.Values{}
			parameters.Add("username", "voicetradingsipvip")
			parameters.Add("password", "164sipviprel")
			//		parameters.Add("charset", "ISO-8859-1")
			parameters.Add("charset", "UTF8")
			parameters.Add("to", smsout.Phoneto)
			//			parameters.Add("to", "+358451202801") /for test
			//							parameters.Add("to", "+358504440106") //for test
			parameters.Add("from", smsout.Phonefrom)
			parameters.Add("text", smsout.Text)

			Url.RawQuery = parameters.Encode()
			urlstr = Url.String()

		}

	} else if provider == "pullpull" {

		if Url, err := url.Parse("http://localhost:13013"); err != nil {

			panic("boom")
		} else {

			if smsout.Opcode == "54" {

				Url.Path += "/cgi-bin/sendsms"
				parameters := url.Values{}
				parameters.Add("username", "dna179029")
				parameters.Add("password", "dna179029")
				//		parameters.Add("charset", "ISO-8859-1")
				parameters.Add("charset", "UTF8")
				parameters.Add("to", smsout.Phoneto)
				parameters.Add("binfo", "2900")
				//				parameters.Add("to", "+358504440106") //for test
				//		parameters.Add("from", smsout.Phonefrom)
				parameters.Add("text", smsout.Text)

				Url.RawQuery = parameters.Encode()
				urlstr = Url.String()

			}
//.........这里部分代码省略.........
开发者ID:sinelga,项目名称:KannelGoInt,代码行数:101,代码来源:smsSendBy.go

示例5: sendToSyslog

func sendToSyslog(message *nats.Msg, syslog *syslog.Writer) {
	logMessage := buildLogMessage(message)
	logger.Debug("message-sent-to-syslog", lager.Data{"message": logMessage})
	err := syslog.Info(logMessage)
	if err != nil {
		logger.Error("logging-to-syslog-failed", err)
		stop <- true
	}
}
开发者ID:mminges,项目名称:nats_to_syslog,代码行数:9,代码来源:main.go

示例6: InsertMobileClient

func InsertMobileClient(golog syslog.Writer, db sql.DB, sqlstr string) {

	if stmt, err := db.Prepare(sqlstr); err != nil {

		golog.Err(err.Error())

	} else {

		if _, err := stmt.Exec(); err != nil {

			golog.Err(err.Error())

		} else {

			golog.Info("New Client arrived!!!")

		}

	}

}
开发者ID:sinelga,项目名称:KannelGoInt,代码行数:21,代码来源:sql2.go

示例7: UpdateAclient

func UpdateAclient(golog syslog.Writer, db sql.DB, sqlstr string) {

	if stmt, err := db.Prepare(sqlstr); err != nil {

		golog.Err(err.Error())

	} else {

		if _, err := stmt.Exec(); err != nil {

			golog.Err(err.Error())

		} else {

			golog.Info("Aclient updated")

		}

	}

}
开发者ID:sinelga,项目名称:KannelGoInt,代码行数:21,代码来源:sql2.go

示例8: newSyslogAdapter

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)
		},
	}
}
开发者ID:flier,项目名称:go.server,代码行数:22,代码来源:logging.go

示例9: SetupGlusterDiskFile

// Get a list of devices from ring file and virtual mount them using libgfapi
func SetupGlusterDiskFile(serverconf *hummingbird.IniFile, logger *syslog.Writer) (map[string]interface{}, error) {
	hashPathPrefix, hashPathSuffix, _ := hummingbird.GetHashPrefixAndSuffix()
	objRing, _ := hummingbird.GetRing("object", hashPathPrefix, hashPathSuffix)
	bindPort := int(serverconf.GetInt("app:object-server", "bind_port", 6000))
	localDevices, _ := objRing.LocalDevices(bindPort)

	globals := make(map[string]interface{})
	globals["disableFallocate"] = serverconf.GetBool("app:object-server", "disable_fallocate", false)
	globals["glusterVolumes"] = make(map[string]*gfapi.Volume)

	var ret int
	var err error
	for _, dev := range localDevices {
		globals["glusterVolumes"].(map[string]*gfapi.Volume)[dev.Device] = new(gfapi.Volume)

		ret = globals["glusterVolumes"].(map[string]*gfapi.Volume)[dev.Device].Init("localhost", dev.Device)
		if ret < 0 {
			return nil, errors.New(fmt.Sprintf("Volume %s: Init() failed with ret = %d", dev.Device, ret))
		}

		ret, err = globals["glusterVolumes"].(map[string]*gfapi.Volume)[dev.Device].SetLogging("", gfapi.LogDebug)
		if ret < 0 {
			//FIXME: There's a bug in SetLogging: err != nil even when ret = 0
			return nil, errors.New(fmt.Sprintf("Volume %s: SetLogging() failed with ret = %d, error = %s", dev.Device, ret, err.Error()))
		}

		ret = globals["glusterVolumes"].(map[string]*gfapi.Volume)[dev.Device].Mount()
		if ret < 0 {
			return nil, errors.New(fmt.Sprintf("Volume %s: Mount() failed with ret = %d", dev.Device, ret))
		}

		logger.Info(fmt.Sprintf("GlusterFS volume %s sucessfully virtual mounted.", dev.Device))
	}

	return globals, nil
}
开发者ID:prashanthpai,项目名称:antbird,代码行数:37,代码来源:gluster_diskfile.go

示例10: Syslog

// Output each metric in the given registry to syslog periodically using
// the given syslogger.  The interval is to be given in seconds.
func Syslog(r Registry, interval int, w *syslog.Writer) {
	for {
		r.Each(func(name string, i interface{}) {
			switch m := i.(type) {
			case Counter:
				w.Info(fmt.Sprintf("counter %s: count: %d", name, m.Count()))
			case Gauge:
				w.Info(fmt.Sprintf("gauge %s: value: %d", name, m.Value()))
			case Healthcheck:
				m.Check()
				w.Info(fmt.Sprintf("healthcheck %s: error: %v", name, m.Error()))
			case Histogram:
				ps := m.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
				w.Info(fmt.Sprintf(
					"histogram %s: count: %d min: %d max: %d mean: %.2f stddev: %.2f median: %.2f 75%%: %.2f 95%%: %.2f 99%%: %.2f 99.9%%: %.2f",
					name,
					m.Count(),
					m.Min(),
					m.Max(),
					m.Mean(),
					m.StdDev(),
					ps[0],
					ps[1],
					ps[2],
					ps[3],
					ps[4],
				))
			case Meter:
				w.Info(fmt.Sprintf(
					"meter %s: count: %d 1-min: %.2f 5-min: %.2f 15-min: %.2f mean: %.2f",
					name,
					m.Count(),
					m.Rate1(),
					m.Rate5(),
					m.Rate15(),
					m.RateMean(),
				))
			case Timer:
				ps := m.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
				w.Info(fmt.Sprintf(
					"timer %s: count: %d min: %d max: %d mean: %.2f stddev: %.2f median: %.2f 75%%: %.2f 95%%: %.2f 99%%: %.2f 99.9%%: %.2f 1-min: %.2f 5-min: %.2f 15-min: %.2f mean: %.2f",
					name,
					m.Count(),
					m.Min(),
					m.Max(),
					m.Mean(),
					m.StdDev(),
					ps[0],
					ps[1],
					ps[2],
					ps[3],
					ps[4],
					m.Rate1(),
					m.Rate5(),
					m.Rate15(),
					m.RateMean(),
				))
			}
		})
		time.Sleep(time.Duration(int64(1e9) * int64(interval)))
	}
}
开发者ID:jmhodges,项目名称:go-metrics,代码行数:64,代码来源:syslog.go

示例11: Hello

func Hello(mod *Model, logger *syslog.Writer, version string) string {
	s := fmt.Sprintf("Model=>%v, Version=>%s", mod, version)
	logger.Info(s)
	return s
}
开发者ID:itpkg,项目名称:inject,代码行数:5,代码来源:ioc_test.go

示例12: Settasks

func Settasks(makeFlag string, days int, quant int, golog syslog.Writer) {

	quantstr := strconv.Itoa(quant)
	daysstr := strconv.Itoa(days)

	var sqlselectstr string

	if makeFlag == "gsm179019" {
		sqlselectstr = "select * from aclients where (block = 0 and sulje = 0 and ennu = 0 and nmake <> '" + makeFlag + "' and opcode in (50,54,56,49,79,'na') and nupdate_make <=adddate(now(), -" + daysstr + ") and rating>5) or (nmake IS NULL and block = 0 and opcode in (50,54,56,49,79,'na')) order by id desc limit " + quantstr
	}
	if makeFlag == "voicetr" {
		sqlselectstr = "select * from aclients where (block = 0 and sulje = 0 and ennu = 0 and nmake <> '" + makeFlag + "' and opcode in (50,54,56,49,79,'na') and nupdate_make <=adddate(now(), -" + daysstr + ")) or (nmake IS NULL and block = 0 and opcode in (50,54,56,49,79,'na')) order by id desc limit " + quantstr
	}
	if makeFlag == "sms179019" {
		sqlselectstr = "select * from aclients where (block = 0 and sulje = 0 and ennu = 0 and nmake <> '" + makeFlag + "' and opcode in (50,54,56,49,79,'na') and nupdate_make <=adddate(now(), -" + daysstr + ") and smsquant>1) or (nmake IS NULL and block = 0 and opcode in (50,54,56,49,79,'na')) order by id desc limit " + quantstr
	}

	if makeFlag == "sms179029" {
		sqlselectstr = "select * from aclients where (block = 0 and sulje = 0 and ennu = 0 and nmake <> '" + makeFlag + "' and opcode in (54) and nupdate_make <=adddate(now(), -" + daysstr + ") ) or (nmake IS NULL and block = 0 and opcode in (54)) order by id desc limit " + quantstr
	}

	db.Raw.Register("SET NAMES utf8")
	var aclienmap = sql.GetMapAclients(*db, sqlselectstr, makeFlag, golog)

	golog.Info("Ready Settask for " + strconv.Itoa(len(aclienmap)))

	if aclientupdate_stmt, err := db.Prepare("update aclients set nmake = ?,nupdate_make = now() where id = ?"); err != nil {

		golog.Err(err.Error())

	} else {

		for _, Aclient := range aclienmap {

			fmt.Println(Aclient.Phone)
			fmt.Println(Aclient.Opcode)
			fmt.Println(Aclient.Nmake)
			fmt.Println("---------")

			if _, _, err := aclientupdate_stmt.Exec(makeFlag, Aclient.Id); err != nil {
				golog.Err(err.Error())
			}

		}

		jsbyte, _ := json.Marshal(aclienmap)

		buff := bytes.NewBuffer(jsbyte)

		client := &http.Client{}

		if req, err := http.NewRequest("POST", "http://latest.kannelgo.sinelgamysql.appspot.com/settasks", buff); err != nil {

			fmt.Printf("Error: %v\n", err)

		} else {

			req.Header.Add("makeFlag", makeFlag)

			if resp, err1 := client.Do(req); err1 != nil {
				fmt.Printf("Error: %v\n", err1)
			} else {
				defer resp.Body.Close()
				body, _ := ioutil.ReadAll(resp.Body)
				fmt.Println("Body: %s\n", body)
			}

		}

	}

}
开发者ID:sinelga,项目名称:KannelGoInt,代码行数:72,代码来源:settasks.go

示例13: Gettasks

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)
				}
			}

		}
	}
}
开发者ID:sinelga,项目名称:KannelGoInt,代码行数:73,代码来源:gettasks.go

示例14: Syslog

// Output each metric in the given registry to syslog periodically using
// the given syslogger.
func Syslog(r Registry, d time.Duration, w *syslog.Writer) {
	for _ = range time.Tick(d) {
		r.Each(func(name string, i interface{}) {
			switch metric := i.(type) {
			case Counter:
				w.Info(fmt.Sprintf("counter %s: count: %d", name, metric.Count()))
			case Gauge:
				w.Info(fmt.Sprintf("gauge %s: value: %d", name, metric.Value()))
			case GaugeFloat64:
				w.Info(fmt.Sprintf("gauge %s: value: %f", name, metric.Value()))
			case Healthcheck:
				metric.Check()
				w.Info(fmt.Sprintf("healthcheck %s: error: %v", name, metric.Error()))
			case Histogram:
				h := metric.Snapshot()
				ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
				w.Info(fmt.Sprintf(
					"histogram %s: count: %d min: %d max: %d mean: %.2f stddev: %.2f median: %.2f 75%%: %.2f 95%%: %.2f 99%%: %.2f 99.9%%: %.2f",
					name,
					h.Count(),
					h.Min(),
					h.Max(),
					h.Mean(),
					h.StdDev(),
					ps[0],
					ps[1],
					ps[2],
					ps[3],
					ps[4],
				))
			case Meter:
				m := metric.Snapshot()
				w.Info(fmt.Sprintf(
					"meter %s: count: %d 1-min: %.2f 5-min: %.2f 15-min: %.2f mean: %.2f",
					name,
					m.Count(),
					m.Rate1(),
					m.Rate5(),
					m.Rate15(),
					m.RateMean(),
				))
			case Timer:
				t := metric.Snapshot()
				ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
				w.Info(fmt.Sprintf(
					"timer %s: count: %d min: %d max: %d mean: %.2f stddev: %.2f median: %.2f 75%%: %.2f 95%%: %.2f 99%%: %.2f 99.9%%: %.2f 1-min: %.2f 5-min: %.2f 15-min: %.2f mean-rate: %.2f",
					name,
					t.Count(),
					t.Min(),
					t.Max(),
					t.Mean(),
					t.StdDev(),
					ps[0],
					ps[1],
					ps[2],
					ps[3],
					ps[4],
					t.Rate1(),
					t.Rate5(),
					t.Rate15(),
					t.RateMean(),
				))
			}
		})
	}
}
开发者ID:ChristianKniep,项目名称:swarmkit,代码行数:68,代码来源:syslog.go


注:本文中的log/syslog.Writer.Info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。