• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang log.D函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/Centny/gwf/log.D函数的典型用法代码示例。如果您正苦于以下问题:Golang D函数的具体用法?Golang D怎么用?Golang D使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: Notify

func (c *Client) Notify(hs *routing.HTTPSession) routing.HResult {
	log.D("Notify->%v", "xxx")
	var addr = hs.R.Header.Get("X-Real-IP")
	if len(addr) < 1 {
		addr = hs.R.RemoteAddr
	}
	hs.R.ParseForm()
	var vals = hs.R.Form
	var sign, sign_type = vals.Get("sign"), vals.Get("sign_type")
	vals.Del("sign")
	vals.Del("sign_type")
	var data = vals.Encode()
	data, _ = url.QueryUnescape(data)
	var err = c.Web.Verify(data, sign, sign_type)
	if err != nil {
		log.W("Client.Notify recieve bad request from address(%v),err:%v->\nsign_type=%v&sign=%v&%v", addr, err, sign_type, sign, data)
		hs.W.WriteHeader(400)
		hs.W.Write([]byte(err.Error()))
		return routing.HRES_RETURN
	}
	log.D("Client.Notify receive verify request from address(%v) by args:\nsign_type=%v&sign=%v&%v\n<-", addr, sign_type, sign, data)
	err = c.H.OnNotify(c, hs)
	if err == nil {
		hs.W.Write([]byte("success"))
	} else {
		log.W("Client.Notify call on notify fail with error(%v)", err)
		hs.W.WriteHeader(400)
		hs.W.Write([]byte(err.Error()))
	}
	return routing.HRES_RETURN
}
开发者ID:Centny,项目名称:alipay,代码行数:31,代码来源:alipay.go


示例2: LoopPing

func (m *MDbs) LoopPing() {
	log.D("MDbs loop ping is started...")
	for m.Running {
		for _, mdb := range m.Dbs {
			if mdb.ping < 1 {
				mdb.ping = 1
				go mdb.TPing()
			}
		}
		time.Sleep(time.Duration(m.Delay) * time.Millisecond)
	}
	log.D("MDbs loop ping is stopped...")
}
开发者ID:Centny,项目名称:dbm,代码行数:13,代码来源:dbm.go


示例3: Create

func (s *SQL_H) Create() (interface{}, error) {
	log.D("SQL_H start connect to %v", s)
	db, err := sql.Open(s.Driver, s.Url)
	if err == nil {
		db.SetMaxIdleConns(s.Idle)
		db.SetMaxOpenConns(s.Max)
		log.D("SQL_H connect to %v success", s)
		return db, nil
	} else {
		log.D("SQL_H connect to %v error->%v", s, err)
		return nil, err
	}
}
开发者ID:Centny,项目名称:dbm,代码行数:13,代码来源:sql.go


示例4: InsertTx

func InsertTx(tx *sql.Tx, o interface{}, tableName string) (int64, error) {
	dfs := parseToDbfield(o)
	s := bytes.Buffer{}
	s.WriteString("insert into ")
	s.WriteString(tableName)
	s.WriteString("(")
	s.WriteString(selectColumn(dfs))
	s.WriteString(")values(")
	s.WriteString(placeholders(dfs))
	s.WriteString(")")
	log.D("sql:%v", s.String())
	log.D("args:%v", args(dfs))
	return dbutil.DbInsert2(tx, s.String(), args(dfs))
}
开发者ID:dgdn,项目名称:goutil,代码行数:14,代码来源:util.go


示例5: Insert

func Insert(o DbModel) (int64, error) {
	dfs := parseToDbfield(o)
	s := bytes.Buffer{}
	s.WriteString("insert into ")
	s.WriteString(o.GetTableName())
	s.WriteString("(")
	s.WriteString(selectColumn(dfs))
	s.WriteString(")values(")
	s.WriteString(placeholders(dfs))
	s.WriteString(")")
	log.D("sql:%v", s.String())
	log.D("args:%v", args(dfs))
	return dbutil.DbInsert(DbConn(), s.String(), args(dfs))
}
开发者ID:dgdn,项目名称:goutil,代码行数:14,代码来源:util.go


示例6: dbQueryStruct

func dbQueryStruct(db *sql.DB, res interface{}, query string, args ...interface{}) error {
	rows, err := db.Query(query, args...)
	if err != nil {
		return err
	}
	cols, err := rows.Columns()
	if err != nil {
		return err
	}
	rval := reflect.ValueOf(res).Elem()

	rtype := rval.Type()
	pls := []interface{}{}
	for _, col := range cols {
		for i := 0; i < rtype.NumField(); i++ {
			if rtype.Field(i).Tag.Get("m2s") == col {
				pls = append(pls, rval.Field(i).Addr().Interface())
			}
		}
	}
	log.D("query:%v \n pls:%v", query, pls)
	if rows.Next() {
		return rows.Scan(pls...)
	}
	return sql.ErrNoRows
}
开发者ID:dgdn,项目名称:goutil,代码行数:26,代码来源:util.go


示例7: UpdateBankPaper

func UpdateBankPaper(rc *impl.RCM_Cmd) (interface{}, error) {
	var uid, bankId int64
	var paperIds, p2bIds, ext string
	err := rc.ValidF(`
		uid,R|I,R:0;
		bankId,R|I,R:0;
		paperIds,R|S,L:0;
		p2bIds,O|S,L:0;
		ext,O|S,L:0;
		`, &uid, &bankId, &paperIds, &p2bIds, &ext)
	if err != nil {
		log.E("UpdateBankPaper arg err:%v", err)
		return 0, err
	}
	extParse := []P2b_Paper{}
	json.Unmarshal([]byte(ext), &extParse)
	rs := []P2b_Paper{}
	paperIdsArr := []int64{}
	err = json.Unmarshal([]byte(paperIds), &paperIdsArr)
	if err != nil {
		return nil, err
	}

	if p2bIds == "" {
		p2bIds = "0"
	}
	sql_ := "delete from ebs_p2b where bank_id=? and tid not in (" + p2bIds + ")"
	var conn *sql.DB = dbMgr.DbConn()
	tx, err := conn.Begin()
	if err != nil {
		return nil, err
	}

	//同步练习
	for _, v := range extParse {
		fmt.Println(tx.Exec("insert into ebs_p2b (tid,bank_id,paper_id,status,add1) values (?,?,?,'N','P')", v.P2bId, bankId, v.PId))
	}
	//同步练习

	if ext != "" {
		sql_ += " and add1='P'"
	} else {
		sql_ += " and (add1!='P' or add1 is null)"
	}
	log.D("%s", sql_)
	if _, err := tx.Exec(sql_, bankId); err != nil {
		tx.Rollback()
		return nil, err
	}
	for _, v := range paperIdsArr {
		if res, err := tx.Exec("insert into ebs_p2b (bank_id,paper_id,status) values (?,?,'N')", bankId, v); err != nil {
			tx.Rollback()
			return nil, err
		} else {
			p2bId, _ := res.LastInsertId()
			rs = append(rs, P2b_Paper{p2bId, v})
		}
	}
	return rs, tx.Commit()
}
开发者ID:tomlovzki,项目名称:ebs,代码行数:60,代码来源:api.go


示例8: CreateBank

func CreateBank(rc *impl.RCM_Cmd) (interface{}, error) {
	log.D("rc CreateBank")
	var uid int64
	var uname string
	var bName string
	err := rc.ValidF(`
		uid,R|I,R:0;
		uname,R|S,L:0;
		bName,R|S,L:0;
		`, &uid, &uname, &bName)
	if err != nil {
		log.E("CreateBank arg err:%v", err)
		return 0, err
	}
	b := &bank.BANK{}
	b.UId = &uid
	b.Name = &bName
	b.UName = &uname
	b.Status = bank.GetString("N")
	b.Public = bank.GetInt(1)

	if n, err := b.C(nil); err != nil {
		log.E("CreateBank err:%v", err)
		return 0, err
	} else {
		return n, nil
	}
}
开发者ID:tomlovzki,项目名称:ebs,代码行数:28,代码来源:srv.go


示例9: Create

func (m *MGO_H) Create() (interface{}, error) {
	if len(m.Url) < 1 || len(m.Name) < 1 {
		return nil, util.Err("the database con/name is empty")
	}
	log.D("MGO_H start dail to %v", m)
	ss, err := tmgo.Dial(m.Url)
	if err == nil {
		log.D("MGO_H dail to %v success", m)
		return ss.DB(m.Name), nil
	}
	log.D("MGO_H dail to %v error->%v", m, err)
	if ss != nil {
		ss.Close()
	}
	return nil, err
}
开发者ID:Centny,项目名称:dbm,代码行数:16,代码来源:mgo.go


示例10: CallC

func CallC(rc *impl.RCM_Cmd) (interface{}, error) {
	var cid = rc.Kvs().StrVal("cid")
	log.D("run_rc_s doing call_c by cid(%v)", cid)
	var cmd = rcs.CmdC(cid)
	if cmd == nil {
		return util.Map{
			"code": -1,
			"err":  "not found",
		}, nil
	}
	var name = rc.StrVal("name")
	var args = rc.MapVal("args")
	log.D("run_rc_s call client by name(%v),args(%v)", name, util.S2Json(args))
	var res, err = cmd.Exec_m(name, args)
	log.D("run_rc_s call client result->%v", util.S2Json(res))
	return res, err
}
开发者ID:Centny,项目名称:cswf,代码行数:17,代码来源:run_rc_s.go


示例11: RunFFCM_S_V

func RunFFCM_S_V(fcfg *util.Fcfg) error {
	if SRV == nil {
		return util.Err("server is not running")
	}
	var listen = fcfg.Val("listen")
	SRV.Hand("", routing.Shared)
	routing.Shared.Print()
	log.D("listen web server on %v", listen)
	return routing.ListenAndServe(listen)
}
开发者ID:Centny,项目名称:ffcm,代码行数:10,代码来源:ffcm_s.go


示例12: ChkIdx

func ChkIdx(C func(string) *tmgo.Collection, indexes map[string]map[string]tmgo.Index) error {
	for cname, index := range indexes {
		tc := C(cname)
		if _, err := tc.Count(); err != nil {
			return err
		}
		log.D("ChkIdx checking index on collection(%v)...", cname)
		idx_l, err := tc.Indexes()
		if err != nil {
			if qerr, ok := err.(*tmgo.QueryError); !ok || qerr.Code != 26 {
				err = util.Err("ChkIdx list indexes fail with error(%v) on collection(%v)", err, cname)
				log.E("%v", err)
				return err
			}
			log.D("ChkIdx the collection(%v) is not found, it will create empty one...", cname)
			err = tc.Create(&tmgo.CollectionInfo{})
			if err != nil {
				err = util.Err("ChkIdx create collection(%v) fail with error(%v)", cname, err)
				log.E("%v", err)
				return err
			}
		}
		exists := map[string]tmgo.Index{}
		for _, idx := range idx_l {
			exists[idx.Name] = idx
		}
		for iname, idx := range index {
			if _, ok := exists[iname]; ok {
				continue
			}
			idx.Name = iname
			err = C(cname).EnsureIndex(idx)
			if err != nil {
				err = util.Err("ChkIdx ensure index by keys(%v),name(%v) fail with error(%v) on collection(%v)", idx.Key, idx.Name, err, cname)
				log.E("%v", err)
				return err
			}
			log.D("ChkIdx ensure index(%v) on collection(%v) success", iname, cname)
		}
	}
	return nil
}
开发者ID:Centny,项目名称:dbm,代码行数:42,代码来源:index.go


示例13: tsql2

func tsql2() {
	db, err := vsql.Open("mysql", "cny:[email protected](127.0.0.1:3306)/test?charset=utf8&loc=Local")
	if err != nil {
		panic(err.Error())
	}
	for {
		_, err := dbutil.DbQueryInt(db, "select 1")
		log.D("%v", err)
		time.Sleep(time.Second)
	}
}
开发者ID:Centny,项目名称:dbm,代码行数:11,代码来源:tsql.go


示例14: TPing

func (m *MDb) TPing() {
	var showlog = ShowLog && (util.Now()-m.log_time > ShowLogTime)
	if showlog {
		m.log_time = util.Now()
		log.D("MDb start ping to %v ", m.String())
	}
	err := m.H.Ping(m.DB)
	if err == nil || err.Error() != "Closed explicitly" {
		if err == nil {
			if showlog {
				log.D("MDb ping to %v success", m.String())
			}
		} else {
			log.E("MDb ping to %v error->%v, will mark to not active", m.String(), err)
		}
		m.lck.Lock()
		m.Active = err == nil
		m.ping = 0
		m.lck.Unlock()
		return
	}
	// m.H.Close(m.DB)
	//do reconnect
	log.E("MDb ping to %v error->%v, will try reconnect", m.String(), err)
	for {
		db, err := m.H.Create()
		if err == nil {
			log.D("MDb connect to %v success, will mark to active", m.String())
			m.lck.Lock()
			m.DB = db
			m.ping = 0
			m.Active = true
			m.lck.Unlock()
			break
		} else {
			log.E("MDb connect to %v error->%v, will retry after 5s", m.String(), err)
			time.Sleep(5 * time.Second)
		}
	}
}
开发者ID:Centny,项目名称:dbm,代码行数:40,代码来源:dbm.go


示例15: run

func run(args []string) {
	defer StopSrv()
	mux := http.NewServeMux()
	mux.Handle("/jsup/", NewSrvMux("/jsup", "www"))

	log.D("running server on %v", "7899")
	s = http.Server{Addr: ":7899", Handler: mux}
	err := s.ListenAndServe()
	if err != nil {
		fmt.Println(err)
	}
	// lock.Done()
}
开发者ID:Centny,项目名称:jsupload,代码行数:13,代码来源:srv.go


示例16: ListData

func ListData() error {
	var ts []TSt
	err := dbutil.DbQueryS(DbCon(), &ts, "select * from ttable where tid>?", 1)
	if err != nil {
		log.D("Err:%v", err.Error())
		return err
	}
	if len(ts) < 1 {
		log.D("Err:%v", "NOT DATA")
		return errors.New("NOT DATA")
	}
	iid, err := dbutil.DbInsert(DbCon(), "insert into ttable(tname,titem,tval,status,time) values('name','item','val','N',now())")
	if err != nil {
		log.D("Err:%v", err.Error())
		return err
	}
	_, err = dbutil.DbUpdate(DbCon(), "delete from ttable where tid=?", iid)
	if err != nil {
		log.D("Err:%v", err.Error())
		return err
	}
	return nil
}
开发者ID:Centny,项目名称:DEM,代码行数:23,代码来源:example.go


示例17: FuncListBankQuestion

func FuncListBankQuestion(uid, bankId int64) ([]QUESTION, error) {
	rs := []QUESTION{}
	usrFilter := ""
	args := []interface{}{bankId, bankId}
	if uid != 0 {
		usrFilter = " and b.uid=?"
		args = append(args, uid)
	}
	conn := dbMgr.DbConn()
	sql_ := `select q.TID, q.NAME, q.BANK_ID, q.PID, q.TAG, q.DESCRIPTION, q.DURATION, q.SCORE, q.Q_ANALYZE, q.TYPE,q.Q_OPTION, q.ANSWER, q.UID, q.UNAME,q2b.score,q2b.ext,q2b.tid,q2b.seq
	from ebs_question q join ebs_q2b q2b on q2b.bank_id=? and q2b.q_id=q.tid join ebs_bank b on b.tid=?` + usrFilter + ` order by q2b.seq asc`
	log.D("sql:%s", sql_)
	if rows, err := conn.Query(sql_, args...); err != nil {
		return rs, err
	} else {
		columns := []string{"TID", "NAME", "BANK_ID", "PID", "TAG", "DESCRIPTION", "DURATION", "SCORE", "Q_ANALYZE", "TYPE",
			"Q_OPTION", "ANSWER", "UID", "UNAME", "SCORE"}
		for rows.Next() {
			vals := []interface{}{}
			b := QUESTION{}
			for _, v := range columns {
				(&b).GetFieldByColumn(v, &vals)
			}
			var ext sql.NullString
			var q2bId int64
			var q2bSeq sql.NullInt64
			vals = append(vals, &ext, &q2bId, &q2bSeq)
			if err := rows.Scan(vals...); err != nil {
				log.E("scan err:%v", err)
			}
			b.Q2bId = q2bId
			b.Q2bSeq = q2bSeq.Int64
			if ext.String != "" {
				extParse := EXT{}
				json.Unmarshal([]byte(ext.String), &extParse)
				b.SCORE = &extParse.Score
				b.DURATION = &extParse.Duration
				b.Ext = extParse
			}
			rs = append(rs, b)
		}
	}
	return rs, nil
}
开发者ID:tomlovzki,项目名称:ebs,代码行数:44,代码来源:func.go


示例18: SrvHTTP

func (v *VideoProc) SrvHTTP(hs *routing.HTTPSession) routing.HResult {
	var tid string
	var duration int64
	err := hs.ValidCheckVal(`
		tid,R|S,L:0;
		duration,R|I,R:0;
		`, &tid, &duration)
	if err != nil {
		return hs.Printf("valid argument error by %v", err)
	}
	var reader = bufio.NewReader(hs.R.Body)
	var frame = util.Map{}
	for {
		bys, err := util.ReadLine(reader, 102400, false)
		if err != nil {
			break
		}
		line := strings.Trim(string(bys), " \n\t")
		lines := strings.SplitN(line, "=", 2)
		lines[0] = strings.Trim(lines[0], " \t")
		if len(lines) < 2 {
			frame[lines[0]] = ""
		} else {
			frame[lines[0]] = lines[1]
		}
		if lines[0] != "progress" {
			continue
		}
		var progress Progress
		frame.ToS(&progress)
		var rate = float64(progress.OutTimeMs) / float64(duration)
		if int(rate*1000)%10 == 0 {
			log.D("NofityProc receive rate(%v%%) to task(%v),duration(%v)", int(rate*100), tid, duration)
		}
		err = v.NotifyProc(tid, rate)
		if err != nil {
			return hs.Printf("notify procgress to task(%v) error by %v", tid, err)
		}
		frame = util.Map{}
	}
	return hs.Printf("%v", "DONE")
}
开发者ID:Centny,项目名称:ffcm,代码行数:42,代码来源:ffcm_c.go


示例19: Build

func (a *AbsV) Build(dtcm *dtm.DTCM_S, id, info interface{}, args ...interface{}) (interface{}, interface{}, []interface{}, error) {
	var src = fmt.Sprintf("%v", args[0])
	video, err := ParseVideo(filepath.Join(a.WDir, src))
	if err != nil {
		err = util.Err("AbsV parse video by src(%v) error->%v", src, err)
		log.E("%v", err)
		return nil, nil, nil, err
	}
	video.Info = info
	video.Alias = a.Alias
	var mv, _ = util.Json2Map(util.S2Json(video))
	var tw, th, dur = video.Width, video.Height, int64(video.Duration * 1000000)
	var dst interface{}
	if len(args) > 1 {
		dst = args[1]
	} else {
		dst = strings.TrimSuffix(src, filepath.Ext(src))
	}
	log.D("AbsV adding task by src(%v),width(%v),height(%v),duration(%v)", src, tw, th, dur)
	return id, mv, []interface{}{
		src, dst, tw, th, dur,
	}, nil
}
开发者ID:Centny,项目名称:ffcm,代码行数:23,代码来源:ffcm_s.go


示例20: Args_m

func Args_m(rc *impl.RCM_Cmd) (interface{}, error) {
	log.D("run_rc_s doing Args_m->%v", util.S2Json(rc.Map))
	return rc.Map, nil
}
开发者ID:Centny,项目名称:cswf,代码行数:4,代码来源:run_rc_s.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang log.E函数代码示例发布时间:2022-05-23
下一篇:
Golang routing.HTTPSession类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap