本文整理汇总了Golang中github.com/qiniu/log.Info函数的典型用法代码示例。如果您正苦于以下问题:Golang Info函数的具体用法?Golang Info怎么用?Golang Info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Info函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: fetch
//获取文件列表并下载文件
//1)获取列表
//2)依次下载列表中每一项对应的文件
//bool:true,fetch 结束
func (p *Rsf) fetch(pos *Pos) (bool, error) {
log.Info("fetching, marker=", pos.Marker)
xl := xlog.NewDummy()
ret, err := p.rsfs.ListPrefix(xl, p.Bucket, p.Config.Prefix, pos.Marker, MAX_LIMIT)
if err != nil {
xl.Error("fetch err:", err, pos, p.Bucket)
return false, err
}
if len(ret.Items) == 0 {
return true, nil
}
for _, i := range ret.Items {
if p.MaxSize <= 0 || i.Fsize <= p.MaxSize {
if p.isNeedReload(i, pos) {
p.download(i, RETRY_TIMES)
} else {
log.Info(i.Name + " already exists,skip!")
}
}
}
pos.Marker = ret.Marker
return len(ret.Items) < MAX_LIMIT, nil
}
开发者ID:rwifeng,项目名称:qiniutools,代码行数:27,代码来源:main.go
示例17: serveUfop
func (this *UfopServer) serveUfop(w http.ResponseWriter, req *http.Request) {
//check method
if req.Method != "POST" {
writeJsonError(w, 405, "method not allowed")
return
}
defer req.Body.Close()
var err error
var ufopReq UfopRequest
var ufopResult interface{}
var ufopResultType int
var ufopResultContentType string
ufopReqData, err := ioutil.ReadAll(req.Body)
if err != nil {
writeJsonError(w, 500, "read ufop request body error")
return
}
reqId := utils.NewRequestId()
log.Info(reqId, string(ufopReqData))
err = json.Unmarshal(ufopReqData, &ufopReq)
if err != nil {
writeJsonError(w, 500, "parse ufop request body error")
return
}
ufopReq.ReqId = reqId
ufopResult, ufopResultType, ufopResultContentType, err = handleJob(ufopReq, this.cfg.UfopPrefix, this.jobHandlers)
if err != nil {
ufopErr := UfopError{
Request: ufopReq,
Error: err.Error(),
}
logBytes, _ := json.Marshal(&ufopErr)
log.Error(reqId, string(logBytes))
writeJsonError(w, 400, err.Error())
} else {
switch ufopResultType {
case RESULT_TYPE_JSON:
writeJsonResult(w, 200, ufopResult)
case RESULT_TYPE_OCTECT_BYTES:
writeOctetResultFromBytes(w, ufopResult, ufopResultContentType)
case RESULT_TYPE_OCTECT_FILE:
writeOctetResultFromFile(w, ufopResult, ufopResultContentType)
case RESULT_TYPE_OCTECT_URL:
writeOctectResultFromUrl(w, ufopResult)
}
}
}
开发者ID:needkane,项目名称:qiniu-ufop-service,代码行数:49,代码来源:server.go
示例18: NewRsf
func NewRsf(baseDir string) (*Rsf, error) {
// load config
conf := Config{}
err := loadJsonFile(&conf, baseDir+"/qrsb.conf")
if err != nil {
log.Error("load qrsb.conf file error!")
return nil, err
}
log.Info("use conf of:", conf)
t := digest_auth.NewTransport(conf.AccessKey, conf.SecretKey, nil)
rsfs := rsf.New(t, conf.RsfHost)
RS_HOST = conf.RsHost
rss := rs.New(t)
return &Rsf{&conf, baseDir, rsfs, rss}, nil
}
开发者ID:rwifeng,项目名称:qiniutools,代码行数:15,代码来源:main.go
示例19: Cache
func (this *DirCache) Cache(cacheRootPath string, cacheResultFile string) (fileCount int) {
if _, err := os.Stat(cacheResultFile); err != nil {
log.Info(fmt.Sprintf("No cache file `%s' found, will create one", cacheResultFile))
} else {
os.Remove(cacheResultFile + ".old")
if rErr := os.Rename(cacheResultFile, cacheResultFile+".old"); rErr != nil {
log.Error(fmt.Sprintf("Unable to rename cache file, plz manually delete `%s' and `%s.old'",
cacheResultFile, cacheResultFile))
log.Error(rErr)
return
}
}
cacheResultFileH, err := os.OpenFile(cacheResultFile, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0666)
if err != nil {
log.Error(fmt.Sprintf("Failed to open cache file `%s'", cacheResultFile))
return
}
defer cacheResultFileH.Close()
bWriter := bufio.NewWriter(cacheResultFileH)
walkStart := time.Now()
log.Debug(fmt.Sprintf("Walk `%s' start from `%s'", cacheRootPath, walkStart.String()))
filepath.Walk(cacheRootPath, func(path string, fi os.FileInfo, err error) error {
var retErr error
//log.Debug(fmt.Sprintf("Walking through `%s'", cacheRootPath))
if !fi.IsDir() {
relPath := strings.TrimPrefix(strings.TrimPrefix(path, cacheRootPath), string(os.PathSeparator))
fsize := fi.Size()
//Unit is 100ns
flmd := fi.ModTime().UnixNano() / 100
//log.Debug(fmt.Sprintf("Hit file `%s' size: `%d' mode time: `%d`", relPath, fsize, flmd))
fmeta := fmt.Sprintln(fmt.Sprintf("%s\t%d\t%d", relPath, fsize, flmd))
if _, err := bWriter.WriteString(fmeta); err != nil {
log.Error(fmt.Sprintf("Failed to write data `%s' to cache file", fmeta))
retErr = err
}
fileCount += 1
}
return retErr
})
if err := bWriter.Flush(); err != nil {
log.Error(fmt.Sprintf("Failed to flush to cache file `%s'", cacheResultFile))
}
walkEnd := time.Now()
log.Debug(fmt.Sprintf("Walk `%s' end at `%s'", cacheRootPath, walkEnd.String()))
log.Debug(fmt.Sprintf("Walk `%s' last for `%s'", cacheRootPath, time.Since(walkStart)))
return
}
开发者ID:micooz,项目名称:qshell,代码行数:48,代码来源:dir_cache.go
示例20: Listen
func (this *LiveServer) Listen() (err error) {
log.Info("start server listening")
endPoint := fmt.Sprintf("%s:%d", this.cfg.ListenHost, this.cfg.ListenPort)
server := &http.Server{
Addr: endPoint,
ReadTimeout: time.Duration(this.cfg.ReadTimeout) * time.Second,
WriteTimeout: time.Duration(this.cfg.WriteTimeout) * time.Second,
MaxHeaderBytes: this.cfg.MaxHeaderBytes,
Handler: this,
}
listenErr := server.ListenAndServe()
if listenErr != nil {
err = listenErr
return
}
return
}
开发者ID:beijingkaka,项目名称:qiniu-live-server,代码行数:17,代码来源:server.go
注:本文中的github.com/qiniu/log.Info函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论