本文整理汇总了Golang中zc-common-go/glog.Errorf函数的典型用法代码示例。如果您正苦于以下问题:Golang Errorf函数的具体用法?Golang Errorf怎么用?Golang Errorf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Errorf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getMemberAllHomes
// get all homes created by uid or uid as a member
func (this *MemberManager) getMemberAllHomes(domain string, uid int64) ([]int64, error) {
SQL := fmt.Sprintf("SELECT hid FROM %s_home_members WHERE uid = ?", domain)
stmt, err := this.store.db.Prepare(SQL)
if err != nil {
log.Errorf("prepare query failed:domain[%s], uid[%d], err[%v]",
domain, uid, err)
return nil, err
}
defer stmt.Close()
rows, err := stmt.Query(uid)
if err != nil {
log.Errorf("query all homes failed:domain[%s], uid[%d], err[%v]",
domain, uid, err)
return nil, err
}
var hid int64
list := make([]int64, 0)
for rows.Next() {
err = rows.Scan(&hid)
if err != nil {
log.Warningf("parse the result failed:domain[%s], uid[%d], err[%v]",
domain, uid, err)
return nil, err
}
list = append(list, hid)
}
return list, nil
}
开发者ID:ericcapricorn,项目名称:device,代码行数:29,代码来源:member_manager.go
示例2: modifyDeviceInfo
// modify device info all column can be modified
func (this *DeviceManager) modifyDeviceInfo(checkStatus bool, domain string, did int64, key string, value interface{}) error {
common.CheckParam(len(key) != 0)
var SQL string
if checkStatus {
SQL = fmt.Sprintf("UPDATE %s_device_info SET %s = ? WHERE did = ? AND status = %d", domain, key, ACTIVE)
} else {
SQL = fmt.Sprintf("UPDATE %s_device_info SET %s = ? WHERE did = ?", domain, key)
}
stmt, err := this.store.db.Prepare(SQL)
if err != nil {
log.Errorf("prepare query failed:err[%v]", err)
return err
}
defer stmt.Close()
result, err := stmt.Exec(value, did)
if err != nil {
log.Errorf("execute update failed:domain[%s], key[%s], value[%v], err[%v]", domain, key, value, err)
return err
}
affect, err := result.RowsAffected()
if err != nil {
log.Warningf("get affected rows failed:err[%v]", err)
return err
}
if affect != 1 {
log.Warningf("update device info failed:domain[%s], key[%s], value[%v], err[%v]", domain, key, value, err)
return common.ErrEntryNotExist
}
return nil
}
开发者ID:ericcapricorn,项目名称:device,代码行数:31,代码来源:device_manager.go
示例3: modifyHome
////////////////////////////////////////////////////////////////////////////////////
// database related private interface
////////////////////////////////////////////////////////////////////////////////////
func (this *HomeManager) modifyHome(domain string, hid int64, key string, value interface{}) error {
SQL := fmt.Sprintf("UPDATE %s_home_info SET %s = ? WHERE hid = ?", domain, key)
stmt, err := this.store.db.Prepare(SQL)
if err != nil {
log.Errorf("prepare query failed:err[%v]", err)
return err
}
defer stmt.Close()
result, err := stmt.Exec(value, hid)
if err != nil {
log.Errorf("execute update failed:sql[%s], err[%v]", SQL, err)
return err
}
affect, err := result.RowsAffected()
if err != nil {
log.Warningf("affected rows failed:err[%v]", err)
return err
}
if affect < 1 {
log.Warningf("check affected rows failed:domain[%s], hid[%d], row[%d]", domain, hid, affect)
return common.ErrAccountNotExist
} else if affect > 1 {
log.Errorf("check affected rows failed:domain[%s], key[%s], value[%v], hid[%d], row[%d]",
domain, key, value, hid, affect)
return common.ErrUnknown
}
return nil
}
开发者ID:ericcapricorn,项目名称:device,代码行数:31,代码来源:home_manager.go
示例4: ChangeDeviceBinding
func (this *BindingProxy) ChangeDeviceBinding(did int64, domain, subDomain, deviceId string) error {
if this.cacheOn {
this.cache.Delete(domain, did)
}
SQL1 := fmt.Sprintf("UPDATE %s_device_mapping SET sub_domain = ?, device_id = ?, bind_token = NULL WHERE did = ?", domain)
stmt, err := this.store.db.Prepare(SQL1)
if err != nil {
log.Errorf("prepare update mapping failed:domain[%s], device[%s:%s], err[%v]", domain, subDomain, deviceId, err)
return err
}
defer stmt.Close()
result, err := stmt.Exec(subDomain, deviceId, did)
if err != nil {
log.Errorf("execute update failed:domain[%s], device[%s:%s], err[%v]", domain, subDomain, deviceId, err)
return err
}
affect, err := result.RowsAffected()
if err != nil {
log.Warningf("get affected rows failed:err[%v]", err)
return err
}
if affect != 1 {
log.Errorf("check affected rows failed:domain[%s], device[%s:%s], err[%v]", domain, subDomain, deviceId, err)
return common.ErrEntryNotExist
}
return nil
}
开发者ID:ericcapricorn,项目名称:device,代码行数:27,代码来源:binding_proxy.go
示例5: Start
// the device point gateway start listen
func (this *DeviceGatewayServer) Start(host string) error {
common.Assert((this.connManager != nil) && (this.devManager != nil), "check param nil")
addr, err := net.ResolveTCPAddr("tcp4", host)
if err != nil {
log.Errorf("resolve tcp addr error:err[%v]", err)
return err
}
ln, err := net.ListenTCP("tcp", addr)
if err != nil {
log.Errorf("listen error:err[%v]", err)
return err
}
var waitGroup sync.WaitGroup
for {
socket, err := ln.AcceptTCP()
if err != nil {
log.Errorf("accept error:err[%v]", err)
continue
}
log.Infof("device connect start:addr[%s]", socket.RemoteAddr())
waitGroup.Add(1)
go this.deviceRoutine(&waitGroup, socket, QueueLen)
}
waitGroup.Wait()
return err
}
开发者ID:ericcapricorn,项目名称:gateway,代码行数:27,代码来源:device_gateway_server.go
示例6: getAllMembers
func (this *MemberManager) getAllMembers(domain string, hid int64) ([]Member, error) {
SQL := fmt.Sprintf("SELECT uid, hid, name, type, status FROM %s_home_members WHERE hid = ?", domain)
stmt, err := this.store.db.Prepare(SQL)
if err != nil {
log.Errorf("prepare query failed:domain[%s], hid[%d], err[%v]", domain, hid, err)
return nil, err
}
defer stmt.Close()
rows, err := stmt.Query(hid)
if err != nil {
log.Errorf("query all members failed:domain[%s], hid[%d], err[%v]",
domain, hid, err)
return nil, err
}
defer rows.Close()
var member Member
list := make([]Member, 0)
for rows.Next() {
err := rows.Scan(&member.uid, &member.hid, &member.memberName, &member.memberType, &member.status)
if err != nil {
log.Errorf("parse the uid failed:domain[%s], hid[%d], err[%v]",
domain, hid, err)
return nil, err
}
list = append(list, member)
}
return list, nil
}
开发者ID:ericcapricorn,项目名称:device,代码行数:28,代码来源:member_manager.go
示例7: modifyMemberInfo
// modify member info all column can be modified
func (this *MemberManager) modifyMemberInfo(domain string, hid, uid int64, key string, value interface{}) error {
common.CheckParam(len(key) != 0)
SQL := fmt.Sprintf("UPDATE %s_home_members SET %s = ? WHERE uid = ? AND hid = ?", domain, key)
stmt, err := this.store.db.Prepare(SQL)
if err != nil {
log.Errorf("prepare query failed:err[%v]", err)
return err
}
defer stmt.Close()
result, err := stmt.Exec(value, uid, hid)
if err != nil {
log.Errorf("execute update failed:sql[%s], err[%v]", SQL, err)
return err
}
affect, err := result.RowsAffected()
if err != nil {
log.Warningf("get affected rows failed:err[%v]", err)
return err
}
if affect < 1 {
log.Warningf("check affected rows failed:domain[%s], hid[%d], uid[%d], row[%d]", domain, hid, uid, affect)
return common.ErrEntryNotExist
} else if affect > 1 {
log.Errorf("check affected rows failed:domain[%s], hid[%d], uid[%d], row[%d]", domain, hid, uid, affect)
return common.ErrUnknown
}
return nil
}
开发者ID:ericcapricorn,项目名称:device,代码行数:29,代码来源:member_manager.go
示例8: handleDevResponse
// handle device response message forward to the result channel
func (this *Connection) handleDevResponse(packet *common.Message) {
request, find := this.requestMap.Find(packet.Header.MsgId)
if find {
// reset to the old message id
packet.Header.MsgId = request.(*DeviceCtrlRequest).oldMessageId
defer func() {
info := recover()
if info != nil {
log.Warningf("the response queue is closed:err[%v]", info)
}
_, exist := this.requestMap.Delete(packet.Header.MsgId)
if !exist {
log.Errorf("delete request failed:mid[%d], code[%d], dest[%s], gid[%s]",
packet.Header.MsgId, packet.Header.MsgCode, this.socket.RemoteAddr(), this.gid.String())
}
log.Infof("delete the request mapping succ:mid[%d], code[%d], dest[%s], gid[%s]",
packet.Header.MsgId, packet.Header.MsgCode, this.socket.RemoteAddr(), this.gid.String())
}()
// if closed will panic
*(request.(*DeviceCtrlRequest).responseQueue) <- *packet
} else {
log.Errorf("check the dev response not find request:mid[%d], code[%d], dest[%s], gid[%s]",
packet.Header.MsgId, packet.Header.MsgCode, this.socket.RemoteAddr(), this.gid.String())
}
}
开发者ID:ericcapricorn,项目名称:gateway,代码行数:26,代码来源:device_connection.go
示例9: GetDeviceInfo
// if not find in database return nil + nil
func (this *WarehouseProxy) GetDeviceInfo(domain, subDomain, deviceId string) (*BasicInfo, error) {
if this.cacheOn {
basic, find := this.cache.Get(domain, subDomain, deviceId)
if find {
log.Infof("get device basic info from cache:domain[%s], device[%s:%s]", domain, subDomain, deviceId)
return basic, nil
}
}
SQL := fmt.Sprintf("SELECT device_type, public_key, status FROM %s_device_warehouse WHERE sub_domain = ? AND device_id = ?", domain)
stmt, err := this.store.db.Prepare(SQL)
if err != nil {
log.Errorf("prepare query failed:err[%v]", err)
return nil, err
}
defer stmt.Close()
basic := NewBasicInfo()
err = stmt.QueryRow(subDomain, deviceId).Scan(&basic.deviceType, &basic.publicKey, &basic.status)
if err != nil {
if err == sql.ErrNoRows {
log.Warningf("no find the device:domain[%s], device[%s:%s]", domain, subDomain, deviceId)
return nil, nil
}
log.Errorf("query failed:domain[%s], device[%s:%s]", domain, subDomain, deviceId)
return nil, err
}
basic.subDomain = subDomain
basic.deviceId = deviceId
if this.cacheOn {
this.cache.Set(domain, basic)
}
return basic, nil
}
开发者ID:ericcapricorn,项目名称:device,代码行数:33,代码来源:warehouse_proxy.go
示例10: NewBindingManager
func NewBindingManager(store *DeviceStorage) *BindingManager {
warehouse := NewDeviceWarehouse(store)
if warehouse == nil {
log.Errorf("new device warehouse failed")
return nil
}
proxy := newBindingProxy(store)
if proxy == nil {
log.Errorf("new binding proxy failed")
return nil
}
return &BindingManager{store: store, warehouse: warehouse, proxy: proxy}
}
开发者ID:ericcapricorn,项目名称:device,代码行数:13,代码来源:binding_manager.go
示例11: deleteHome
func (this *HomeManager) deleteHome(domain string, hid int64) error {
SQL := fmt.Sprintf("DELETE FROM %s_home_info WHERE hid = ?", domain)
stmt, err := this.store.db.Prepare(SQL)
if err != nil {
log.Errorf("prepare query failed:err[%v]", err)
return err
}
defer stmt.Close()
_, err = stmt.Exec(hid)
if err != nil {
log.Errorf("insert a new home failed:domain[%s], hid[%d], err[%v]", domain, hid, err)
return err
}
return nil
}
开发者ID:ericcapricorn,项目名称:device,代码行数:15,代码来源:home_manager.go
示例12: InsertDeviceInfo
func (this *WarehouseProxy) InsertDeviceInfo(domain, subDomain, deviceId, publicKey string, master bool) error {
var SQL string
if master {
SQL = fmt.Sprintf("INSERT INTO %s_device_warehouse(sub_domain, device_id, device_type, public_key, status) VALUES(?,?,?,?,?)", domain)
} else {
SQL = fmt.Sprintf("INSERT INTO %s_device_warehouse(sub_domain, device_id, device_type, status) VALUES(?,?,?,?)", domain)
}
stmt, err := this.store.db.Prepare(SQL)
if err != nil {
log.Errorf("prepare query failed:err[%v]", err)
return err
}
defer stmt.Close()
if master {
_, err = stmt.Exec(subDomain, deviceId, MASTER, publicKey, ACTIVE)
} else {
_, err = stmt.Exec(subDomain, deviceId, NORMAL, ACTIVE)
}
if err != nil {
log.Warningf("execute insert device[%s:%s] failed:domain[%s], err[%v]", subDomain, deviceId, domain, err)
return err
}
if this.cacheOn {
this.cache.Delete(domain, subDomain, deviceId)
}
return nil
}
开发者ID:ericcapricorn,项目名称:device,代码行数:27,代码来源:warehouse_proxy.go
示例13: IsBindingExist
func (this *BindingProxy) IsBindingExist(domain string, did int64, exist *bool) error {
if this.cacheOn {
_, find := this.cache.Get(domain, did)
if find {
*exist = true
return nil
}
}
SQL := fmt.Sprintf("SELECT did FROM %s_device_mapping WHERE did = ?", domain)
stmt, err := this.store.db.Prepare(SQL)
if err != nil {
log.Errorf("prepare query failed:domain[%s], did[%d], err[%v]", domain, did, err)
return err
}
defer stmt.Close()
var value int64
err = stmt.QueryRow(did).Scan(&value)
if err != nil {
if err == sql.ErrNoRows {
*exist = false
} else {
log.Warningf("get binding info failed:domain[%s], did[%d], err[%v]", domain, did, err)
return err
}
}
*exist = true
return nil
}
开发者ID:ericcapricorn,项目名称:device,代码行数:28,代码来源:binding_proxy.go
示例14: GetBindingInfo
// get by device global key, if not exist return nil + nil
func (this *BindingProxy) GetBindingInfo(domain, subDomain, deviceId string) (*BindingInfo, error) {
SQL := fmt.Sprintf("SELECT did, bind_token, expire_time FROM %s_device_mapping WHERE sub_domain = ? AND device_id = ?", domain)
stmt, err := this.store.db.Prepare(SQL)
if err != nil {
log.Errorf("prepare query failed:domain[%s], device[%s:%s], err[%v]",
domain, subDomain, deviceId, err)
return nil, err
}
defer stmt.Close()
bind := NewBindingInfo()
err = stmt.QueryRow(subDomain, deviceId).Scan(&bind.did, &bind.grantToken, &bind.grantTime)
if err != nil {
if err != sql.ErrNoRows {
log.Warningf("query binding info failed:domain[%s], device[%s:%s], err[%v]",
domain, subDomain, deviceId, err)
} else {
err = common.ErrEntryNotExist
}
return nil, err
}
bind.subDomain = subDomain
bind.deviceId = deviceId
if this.cacheOn {
this.cache.Set(domain, bind)
}
return bind, nil
}
开发者ID:ericcapricorn,项目名称:device,代码行数:28,代码来源:binding_proxy.go
示例15: rollback
//////////////////////////////////////////////////////////////////////////////
/// private interface related to database
//////////////////////////////////////////////////////////////////////////////
// transaction rollback according to the error status
func rollback(err *error, tx *sql.Tx) {
if *err != nil {
log.Infof("error occured rollback:err[%v]", *err)
newErr := tx.Rollback()
if newErr != nil {
log.Errorf("rollback failed:err[%v]", newErr)
}
}
}
开发者ID:ericcapricorn,项目名称:device,代码行数:13,代码来源:binding_proxy.go
示例16: NewDeviceStorage
func NewDeviceStorage(host, user, password, database string) *DeviceStorage {
dns := fmt.Sprintf("%s:%[email protected](%s)/%s", user, password, host, database)
driver, err := sql.Open("mysql", dns)
if err != nil {
log.Errorf("open MySQL Driver failed:dns[%s], err[%v]", dns, err)
return nil
}
return &DeviceStorage{db: driver, database: database}
}
开发者ID:ericcapricorn,项目名称:device,代码行数:9,代码来源:device_storage.go
示例17: getDeviceInfo
// get device info
func (this *DeviceManager) getDeviceInfo(domain string, did int64, device *DeviceInfo) error {
SQL := fmt.Sprintf("SELECT did, hid, name, status, master_did FROM %s_device_info WHERE did = ?", domain)
stmt, err := this.store.db.Prepare(SQL)
if err != nil {
log.Errorf("prepare query failed:domain[%s], did[%d], err[%v]", domain, did, err)
return err
}
defer stmt.Close()
err = stmt.QueryRow(did).Scan(&device.did, &device.hid, &device.deviceName, &device.status, &device.masterDid)
if err != nil {
if err == sql.ErrNoRows {
return common.ErrEntryNotExist
} else {
log.Errorf("get deive info failed:domain[%s], did[%d]", domain, did)
return err
}
}
return nil
}
开发者ID:ericcapricorn,项目名称:device,代码行数:20,代码来源:device_manager.go
示例18: DeleteDeviceInfo
func (this *WarehouseProxy) DeleteDeviceInfo(domain, subDomain, deviceId string) error {
if this.cacheOn {
this.cache.Delete(domain, subDomain, deviceId)
}
SQL := fmt.Sprintf("DELETE FROM %s_device_warehouse WHERE sub_domain = ? AND device_id = ?", domain)
stmt, err := this.store.db.Prepare(SQL)
if err != nil {
log.Errorf("prepare query failed:err[%v]", err)
return err
}
defer stmt.Close()
_, err = stmt.Exec(subDomain, deviceId)
if err != nil {
log.Errorf("delete the device failed:domain[%s], subDomain[%s], deviceId[%s], err[%s]",
domain, subDomain, deviceId, err)
return err
}
return nil
}
开发者ID:ericcapricorn,项目名称:device,代码行数:19,代码来源:warehouse_proxy.go
示例19: Clean
// just for unit test warning
func (this *DeviceStorage) Clean(domain, table string) error {
if this.database != "device_test" {
log.Error("clean interface only can be used by test")
return common.ErrNotAllowed
}
SQL := fmt.Sprintf("DELETE FROM %s_%s", domain, table)
stmt, err := this.db.Prepare(SQL)
if err != nil {
log.Errorf("prepare query failed:domain[%s], table[%s], err[%v]", domain, table, err)
return err
}
defer stmt.Close()
_, err = stmt.Exec()
if err != nil {
log.Errorf("delete failed:domain[%s], table[%s], err[%v]", domain, table, err)
return err
}
return nil
}
开发者ID:ericcapricorn,项目名称:device,代码行数:20,代码来源:device_storage.go
示例20: insertHome
func (this *HomeManager) insertHome(domain string, uid int64, name string) (int64, error) {
// TODO modify this in one transaction
SQL := fmt.Sprintf("INSERT INTO %s_home_info(name, status, create_uid) VALUES(?,?,?)", domain)
stmt, err := this.store.db.Prepare(SQL)
if err != nil {
log.Errorf("prepare query failed:err[%v]", err)
return -1, err
}
defer stmt.Close()
result, err := stmt.Exec(name, ACTIVE, uid)
if err != nil {
log.Errorf("create new home failed:domain[%s], createUid[%d], name[%s], err[%v]", domain, uid, name, err)
return -1, err
}
hid, err := result.LastInsertId()
if err != nil {
log.Errorf("get last insert id failed:domain[%s], createUid[%d], name[%s], err[%v]", domain, uid, name, err)
return -1, err
}
return hid, nil
}
开发者ID:ericcapricorn,项目名称:device,代码行数:21,代码来源:home_manager.go
注:本文中的zc-common-go/glog.Errorf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论