當前位置: 首頁>>代碼示例>>Golang>>正文


Golang log.Info函數代碼示例

本文整理匯總了Golang中github.com/qiniu/log.Info函數的典型用法代碼示例。如果您正苦於以下問題:Golang Info函數的具體用法?Golang Info怎麽用?Golang Info使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Info函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: download

//下載文件item.Name
//retry:重試次數
func (p *Rsf) download(item rsf.DumpItem, retry int) (err error) {
	log.Info("downloading file :", item.Name, " ,file size = ", item.Fsize, "bytes")
	for i := 1; i <= retry; i++ {
		code, err := p.getFile(item.Name)
		if err == nil {
			log.Info("download completed!")
			return nil
		}
		log.Error("getFile err:", code, err)
		if code == 612 {
			break
		}
		log.Error("retry download ", item.Name, " ", i, " times")
		time.Sleep(SLEEP_TIME)

	}
	//重試retry次後,下載失敗
	ffail, err := os.OpenFile(p.baseDir+"/qrsb.failkeys", os.O_CREATE|os.O_RDWR|os.O_APPEND, 0660)
	if err == nil {
		defer ffail.Close()
		b, err := json.Marshal(item)
		if err == nil {
			ffail.WriteString(string(b))
		}
	} else {
		log.Error("Open qrsb.failkeys err")
		return err
	}
	return
}
開發者ID:rwifeng,項目名稱:qiniutools,代碼行數:32,代碼來源:main.go

示例2: main

func main() {
	var err error
	err = database.InitDB(opts.Driver, opts.DataSource)
	if err != nil {
		log.Fatal(err)
	}
	log.Info("gobuild service stated ...")

	http.Handle("/", m)
	http.Handle("/websocket/", websocket.Handler(WsBuildServer))
	http.HandleFunc("/hello", HelloServer)

	if *secure {
		go func() {
			er := http.ListenAndServeTLS(":443", "bin/ssl.crt", "bin/ssl.key", nil)
			if er != nil {
				log.Error(er)
			}
		}()
	}
	err = http.ListenAndServe(opts.ListenAddr, nil)
	if err != nil {
		log.Fatal(err)
	}
}
開發者ID:matm,項目名稱:gobuild,代碼行數:25,代碼來源:main.go

示例3: Run

func (p *Instance) Run(addr string) error {
	mux := http.NewServeMux()
	mux.HandleFunc("/short", p.HandleShort)
	mux.HandleFunc("/", p.HandleRedirect)
	log.Info("running at:", addr)
	return http.ListenAndServe(addr, mux)
}
開發者ID:wangtuanjie,項目名稱:golang-slides,代碼行數:7,代碼來源:server.go

示例4: RunWithRetry

func (p *Program) RunWithRetry() {
	for p.retry = 0; p.retry < p.Info.StartRetries+1; p.retry += 1 {
		// wait program to exit
		errc := GoFunc(p.Run)
		var err error

	PROGRAM_WAIT:
		// Here is RUNNING State
		select {
		case err = <-errc:
			log.Info(p.Info.Name, err)
		case <-time.After(time.Second * time.Duration(p.Info.StartSeconds)): // reset retry
			p.retry = 0
			goto PROGRAM_WAIT
		case <-p.stopc:
			return
		}

		// Enter RETRY_WAIT State
		if p.retry < p.Info.StartRetries {
			p.setStatus(ST_RETRYWAIT)
			select {
			case <-p.stopc:
				return
			case <-time.After(time.Second * 2):
			}
		}
	}
	p.setStatus(ST_FATAL)
}
開發者ID:mehulsbhatt,項目名稱:gosuv,代碼行數:30,代碼來源:program.go

示例5: QiniuUpload

func QiniuUpload(cmd string, params ...string) {
	if len(params) == 1 || len(params) == 2 {
		var uploadConfigFile string
		var threadCount int64
		var err error
		if len(params) == 2 {
			threadCount, err = strconv.ParseInt(params[0], 10, 64)
			if err != nil {
				log.Error("Invalid <ThreadCount> value,", params[0])
				return
			}
			uploadConfigFile = params[1]
		} else {
			uploadConfigFile = params[0]
		}
		if threadCount < qshell.MIN_UPLOAD_THREAD_COUNT ||
			threadCount > qshell.MAX_UPLOAD_THREAD_COUNT {
			log.Info("You can set <ThreadCount> value between 1 and 100 to improve speed")
			threadCount = qshell.MIN_UPLOAD_THREAD_COUNT
		}
		qshell.QiniuUpload(int(threadCount), uploadConfigFile)
	} else {
		CmdHelp(cmd)
	}
}
開發者ID:xiqingxl,項目名稱:qshell,代碼行數:25,代碼來源:qupload.go

示例6: main

func main() {
	if len(os.Args) < 2 {
		fmt.Println("qrsb <dir>")
		os.Exit(1)
	}
	p, err := NewRsf(os.Args[1])
	if err != nil {
		log.Error("err:", err)
		os.Exit(2)
	}
	if p.isFirstRun() {
		p.firstRun()
	}
	// check pos
	pos := Pos{}
	err = loadJsonFile(&pos, p.baseDir+"/qrsb.pos")
	// pos.Marker = "" //置空,重新開始
	if err != nil {
		log.Error("err:load qrsb.pos file failed,ABORT!")
		os.Exit(2)
	}
	err = p.Run(&pos)
	if err != nil {
		log.Error("err:", err)
		p.printResult()
		os.Exit(2)
	}
	log.Info("Done!")
	p.printResult()
	return
}
開發者ID:rwifeng,項目名稱:qiniutools,代碼行數:31,代碼來源:main.go

示例7: handleRead

func handleRead(ctx context.Context, c *client.Client) error {
	_, data, _, err := c.Read(ctx, readName, readOffset, readLen, readExpChecksum)
	if err != nil {
		log.Fatalf("Read err (%v)", err)
	}
	log.Info(string(data))

	return nil
}
開發者ID:missmayo,項目名稱:cfs,代碼行數:9,代碼來源:read_command.go

示例8: Parse

func (r *RESTFullArgsParse) Parse(env *ReqEnv, typ reflect.Type) (vl reflect.Value, parsed bool) {

	parsed = strings.HasSuffix(typ.Name(), "ArgsRest")
	if !parsed {
		return
	}

	if _, ok := parserCache[typ]; !ok {
		parserCache[typ] = r
	}
	vl = reflect.New(typ).Elem()
	qrys := parseQuery(env.Req.URL.Path)

	if env.Req.Method == "POST" {
		env.Req.ParseForm()
	}

	post := func(key string) string {
		return env.Req.FormValue(key)
	}
	fun := func(qryName string) string {
		if qry, ok := qrys[qryName]; ok {
			return qry
		}
		return post(qryName)
	}

	for i := 0; i < typ.NumField(); i++ {
		qryName := typ.Field(i).Name
		qryName = strings.ToLower(qryName)

		qry := fun(qryName)
		log.Info(qryName, qry)
		tn := typ.Field(i).Type.Name()
		switch tn {
		case "string":
			vl.Field(i).SetString(qry)
		case "int":
			if ival, err := strconv.Atoi(qry); err == nil {
				vl.Field(i).SetInt(int64(ival))
			}
		case "int64":
			if ival, err := strconv.ParseInt(qry, 10, 64); err == nil {
				vl.Field(i).SetInt(int64(ival))
			}
		case "bool":
			if ival, err := strconv.ParseBool(qry); err == nil {
				vl.Field(i).SetBool(ival)
			}
		case "float64":
			if ival, err := strconv.ParseFloat(qry, 64); err == nil {
				vl.Field(i).SetFloat(ival)
			}
		}
	}
	return
}
開發者ID:stone5495,項目名稱:tgw,代碼行數:57,代碼來源:argsParser.go

示例9: handleRemove

func handleRemove(ctx context.Context, c *client.Client) error {
	err := c.Remove(ctx, removeName, removeAll)
	if err != nil {
		log.Fatalf("Read err (%v)", err)
	}
	log.Info("remove succeeded")

	return nil
}
開發者ID:missmayo,項目名稱:cfs,代碼行數:9,代碼來源:remove_command.go

示例10: saveKeyPath

func (p *Rsf) saveKeyPath(xl *xlog.Logger, rawKey, key string, r io.Reader) error {
	filename := p.baseDir + "/data/" + rawKey
	dir := path.Dir(filename)
	err := os.MkdirAll(dir, 0700)
	if err != nil {
		log.Info("saveKeyPath os.MkdirAll fail:", err)
		return p.saveKey(xl, key, r)
	}
	f, err := os.Create(filename)
	if err != nil {
		log.Info("saveKeyPath os.Create fail:", err)
		return p.saveKey(xl, key, r)
	}
	defer f.Close()
	_, err = io.Copy(f, r)
	log.Info("save key (path) done:", rawKey, err)
	return err
}
開發者ID:rwifeng,項目名稱:qiniutools,代碼行數:18,代碼來源:main.go

示例11: newLogger

func newLogger(logPath string) {
	os.MkdirAll(path.Dir(logPath), os.ModePerm)

	f, err := os.OpenFile(logPath, os.O_WRONLY|os.O_APPEND|os.O_CREATE, os.ModePerm)
	if err != nil {
		qlog.Fatal(err)
	}

	qlog.SetOutput(f)
	qlog.Info("Start logging serv...")
}
開發者ID:hilerchyn,項目名稱:gogs,代碼行數:11,代碼來源:serve.go

示例12: hello

func hello(rw http.ResponseWriter) {
	ticker := time.NewTicker(2e9)
	for {
		select {
		case <-ticker.C:
			rw.Write(ToByte("hello."))
			log.Info("hello")
		default:
		}
	}
}
開發者ID:everfore,項目名稱:gotest,代碼行數:11,代碼來源:main.go

示例13: newUpdateLogger

func newUpdateLogger(execDir string) {
	logPath := execDir + "/log/update.log"
	os.MkdirAll(path.Dir(logPath), os.ModePerm)

	f, err := os.OpenFile(logPath, os.O_WRONLY|os.O_APPEND|os.O_CREATE, os.ModePerm)
	if err != nil {
		qlog.Fatal(err)
	}

	qlog.SetOutput(f)
	qlog.Info("Start logging update...")
}
開發者ID:numo16,項目名稱:gogs,代碼行數:12,代碼來源:update.go

示例14: OpenChangeLog

func OpenChangeLog(stateDir, eigen string) (cl changelog.Logger, urls []string, err error) {

	h := md5.New()
	h.Write([]byte(eigen))
	hash := h.Sum([]byte{'2', '0'})

	clname := stateDir + base64.URLEncoding.EncodeToString(hash) + ".log"

	log.Info("Processing file:", clname)
	cl, urls, err = changelog.Open(clname)

	return
}
開發者ID:rwifeng,項目名稱:qiniutools,代碼行數:13,代碼來源:fetch.go

示例15: newLogger

func newLogger(execDir string) {
	logPath := execDir + "/log/serv.log"
	os.MkdirAll(path.Dir(logPath), os.ModePerm)

	f, err := os.OpenFile(logPath, os.O_WRONLY|os.O_APPEND|os.O_CREATE, os.ModePerm)
	if err != nil {
		qlog.Fatal(err)
	}

	qlog.SetOutput(f)
	//qlog.SetOutputLevel(qlog.Ldebug)
	qlog.Info("Start logging serv...")
}
開發者ID:CubeLite,項目名稱:gogs,代碼行數:13,代碼來源:serve.go


注:本文中的github.com/qiniu/log.Info函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。