本文整理汇总了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
}
示例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)
}
}
示例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)
}
示例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)
}
示例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)
}
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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...")
}
示例12: hello
func hello(rw http.ResponseWriter) {
ticker := time.NewTicker(2e9)
for {
select {
case <-ticker.C:
rw.Write(ToByte("hello."))
log.Info("hello")
default:
}
}
}
示例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...")
}
示例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
}
示例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...")
}