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


Golang log.E函数代码示例

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


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

示例1: 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

示例2: migrateAddColumn

func migrateAddColumn(db *sql.DB, table, column, typ, defaul, comment string) error {
	log.I("begin to add column[%s] to the table[%s]...", column, table)

	exists, err := tableColumnExist(db, table, column)
	if err != nil {
		log.E("get table column exists fail %v", err.Error())
		return err
	}
	if exists == false {
		_, err := db.Exec(fmt.Sprintf(`ALTER TABLE %s ADD %s %s default %s comment '%s';`, table, column, typ, defaul, comment))
		if err != nil {
			log.E("add column[%s] fail %v", column, err.Error())
			return err
		}
		log.I("have added column[%s] to the table[%s]", column, table)

		//set the old data of this field to default value
		_, err = db.Exec(fmt.Sprintf(`update %s set %s = ?`, table, column), "")
		return err

	} else {
		log.I("column[%s] already exists no need to add", column)
	}
	return nil
}
开发者ID:dgdn,项目名称:goutil,代码行数:25,代码来源:db.go

示例3: LogErr

func LogErr(err error, reason string) error {
	_, file, line, _ := runtime.Caller(1)
	if err != nil {
		log.E("%v:%v %v:%v", file, line, reason, err.Error())

	} else {
		log.E(reason)
	}
	return errors.New(reason)
}
开发者ID:dgdn,项目名称:goutil,代码行数:10,代码来源:var.go

示例4: 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

示例5: LogNErr

func LogNErr(err error) error {
	_, file, line, _ := runtime.Caller(1)
	if err != nil {
		log.E("%v:%v %v", file, line, err.Error())

	}
	return err
}
开发者ID:dgdn,项目名称:goutil,代码行数:8,代码来源:var.go

示例6: SimpleHandle

func SimpleHandle(fn func(*routing.HTTPSession) (interface{}, error)) routing.HandleFunc {
	return func(hs *routing.HTTPSession) routing.HResult {
		rst, err := fn(hs)
		if err != nil {
			log.E("err:%v", err.Error())
			return hs.MsgResE(1, err.Error())
		}
		return _common.MsgRes(hs, rst)
	}
}
开发者ID:dgdn,项目名称:goutil,代码行数:10,代码来源:http.go

示例7: 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

示例8: GetBankItemCnt

func GetBankItemCnt(rc *impl.RCM_Cmd) (interface{}, error) {
	var bankIds string
	err := rc.ValidF(`
		bankIds,R|S,L:0;
		`, &bankIds)
	if err != nil {
		log.E("GetBankItemCnt arg err:%v", err)
		return 0, err
	}
	return bank.GetBankQcAndPc(bankIds)
}
开发者ID:tomlovzki,项目名称:ebs,代码行数:11,代码来源:api.go

示例9: AttendBankInfo

func AttendBankInfo(rc *impl.RCM_Cmd) (interface{}, error) {
	var bankIds string
	err := rc.ValidF(`
		bankIds,R|S,L:0;
		`, &bankIds)
	if err != nil {
		log.E("AttendBankInfo arg err:%v", err)
		return 0, err
	}
	return bank.AttendBankInfo(bankIds)
}
开发者ID:tomlovzki,项目名称:ebs,代码行数:11,代码来源:api.go

示例10: ListBankPaper

func ListBankPaper(rc *impl.RCM_Cmd) (interface{}, error) {
	var uid, bankId int64
	err := rc.ValidF(`
		uid,O|I,R:0;
		bankId,R|I,R:0;
		`, &uid, &bankId)
	if err != nil {
		log.E("ListBankPaper arg err:%v", err)
		return 0, err
	}
	return bank.FuncListBankPaper(uid, bankId)
}
开发者ID:tomlovzki,项目名称:ebs,代码行数:12,代码来源:api.go

示例11: GetBankPaperScore

func GetBankPaperScore(rc *impl.RCM_Cmd) (interface{}, error) {
	var bankId, paperId int64
	err := rc.ValidF(`
		bankId,R|I,R:0;
		paperId,R|I,R:0;
		`, &bankId, &paperId)
	if err != nil {
		log.E("GetBankPaperScore arg err:%v", err)
		return 0, err
	}
	return bank.GetBankPaperScore(bankId, paperId)
}
开发者ID:tomlovzki,项目名称:ebs,代码行数:12,代码来源:api.go

示例12: 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

示例13: GetUsrPaperRecord

func GetUsrPaperRecord(rc *impl.RCM_Cmd) (interface{}, error) {
	var p2bIds string
	var uid int64
	err := rc.ValidF(`
		p2bIds,R|S,L:0;
		userId,R|I,R:0;
		`, &p2bIds, &uid)
	if err != nil {
		log.E("GetUsrPaperRecord arg err:%v", err)
		return 0, err
	}
	return bank.GetUsrPaperRecord(uid, p2bIds)
}
开发者ID:tomlovzki,项目名称:ebs,代码行数:13,代码来源:api.go

示例14: SimpleListHandle

func SimpleListHandle(fn func(*routing.HTTPSession) (interface{}, int64, error)) routing.HandleFunc {
	return func(hs *routing.HTTPSession) routing.HResult {
		list, total, err := fn(hs)
		if err != nil {
			log.E("err:%v", err.Error())
			return hs.MsgResE(1, err.Error())
		}
		return _common.MsgRes(hs, map[string]interface{}{
			"total": total,
			"list":  list,
		})
	}
}
开发者ID:dgdn,项目名称:goutil,代码行数:13,代码来源:http.go

示例15: MakeDataAccessFilter

func MakeDataAccessFilter(f func(*routing.HTTPSession) (bool, error)) routing.HandleFunc {
	return func(hs *routing.HTTPSession) routing.HResult {
		pass, err := f(hs)
		if err != nil {
			log.E("检验当前用户数据权限失败-%v", err.Error())
			return _common.MsgResE(hs, 1, "检验当前用户数据权限失败")
		}
		if !pass {
			return _common.MsgResE(hs, 1, "当前用户没权限访问该数据")
		}
		return routing.HRES_CONTINUE
	}
}
开发者ID:dgdn,项目名称:goutil,代码行数:13,代码来源:http.go


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