本文整理汇总了Golang中server/libs/log.LogError函数的典型用法代码示例。如果您正苦于以下问题:Golang LogError函数的具体用法?Golang LogError怎么用?Golang LogError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LogError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GlobalDataAddRowValues
func (gd *GlobalDataHelper) GlobalDataAddRowValues(sender rpc.Mailbox, msg *rpc.Message) (errcode int32, reply *rpc.Message) {
var index int
var name string
var row int
var val []datatype.Any
if err := ParseArgs(msg, &index, &name, &row, &val); err != nil {
log.LogError(err)
return share.ERR_ARGS_ERROR, nil
}
args := make([]interface{}, len(val))
for k, v := range val {
args[k] = v.Val
}
index, err := gd.AddRowValues(index, name, row, args...)
if err != nil {
log.LogError(err)
}
if index == -1 {
log.LogError("add record row failed")
}
return 0, nil
}
示例2: SyncPlayerBak
func (b *BaseProxy) SyncPlayerBak(mailbox rpc.Mailbox, info map[ObjectID]ObjectID) error {
//同步数据
player := App.players.GetPlayer(mailbox)
if player == nil {
log.LogError("player not found")
}
for k, v := range info {
ent := App.GetEntity(k)
if ent == nil {
log.LogError("object not found")
continue
}
ent.SetExtraData("linkObj", v)
}
var err error
if player.Quit {
App.players.RemovePlayer(mailbox)
err = server.MailTo(&mailbox,
&player.Base,
"AreaBridge.RemovePlayerBak",
"ok",
)
}
return err
}
示例3: work
func (t *Thread) work(id int) {
log.LogMessage(t.TAG, " thread work, id:", id)
var start_time time.Time
var delay time.Duration
warninglvl := 50 * time.Millisecond
for {
select {
case rpc := <-t.Queue[id]:
log.LogMessage(t.TAG, " thread:", id, rpc.GetSrc(), " call:", rpc.GetMethod())
start_time = time.Now()
err := rpc.Call()
if err != nil {
log.LogError("rpc error:", err)
}
delay = time.Now().Sub(start_time)
if delay > warninglvl {
log.LogWarning("rpc call ", rpc.GetMethod(), " delay:", delay.Nanoseconds()/1000000, "ms")
}
err = rpc.Done()
if err != nil {
log.LogError("rpc error:", err)
}
rpc.Free()
break
default:
if t.Quit {
log.LogMessage(t.TAG, " thread ", id, " quit")
return
}
time.Sleep(time.Millisecond)
}
}
}
示例4: RpcProcess
//进程rpc处理
func RpcProcess(ch chan *rpc.RpcCall) {
var start_time time.Time
var delay time.Duration
for {
select {
case call := <-ch:
if call.IsThreadWork() {
busy = true
} else {
log.LogDebug(call.GetSrc(), " rpc call:", call.GetMethod())
start_time = time.Now()
err := call.Call()
if err != nil {
log.LogError(err)
}
delay = time.Now().Sub(start_time)
if delay > warninglvl {
log.LogWarning("rpc call ", call.GetMethod(), " delay:", delay.Nanoseconds()/1000000, "ms")
}
err = call.Done()
if err != nil {
log.LogError(err)
}
call.Free()
busy = true
}
default:
return
}
}
}
示例5: OnLoadGlobalData
//数据库加载回调
func (gd *GlobalDataHelper) OnLoadGlobalData(msg *rpc.Message) {
ret := GetReplyError(msg)
if ret == share.ERR_REPLY_FAILED {
log.LogError("global data is empty")
if err := gd.createDataSet(); err != nil {
log.LogError("create global data error:", err)
}
return
}
if ret != share.ERR_REPLY_SUCCEED {
log.LogError("global data load error, errcode:", ret)
return
}
var callbackparams share.DBParams
var savedata share.DbSave
if err := ParseArgs(msg, &callbackparams, &savedata); err != nil {
log.LogError("load global data error:", err)
return
}
ent, err := core.CreateFromDb(&savedata)
if err != nil {
log.LogError("create global data set failed, err:", err)
}
if gd.dataset != nil {
core.Destroy(gd.dataset.GetObjId())
}
gd.dataset = ent
gd.ready = true
gd.OnDataReady()
log.LogMessage("load global succeed")
}
示例6: Start
func Start(startapp string, name string, appuid int32, typ string, startargs string) error {
ferr, err := os.Create(fmt.Sprintf("log/%s_err.log", name))
if err != nil {
log.LogError(err)
return err
}
fout, err := os.Create(fmt.Sprintf("log/%s_trace.log", name))
if err != nil {
log.LogError(err)
return err
}
cmd := exec.Command(startapp, "-m", fmt.Sprintf("%s:%d", context.Host, context.Port), "-l", context.LocalIP, "-o", context.OuterIP, "-d", strconv.Itoa(int(appuid)), "-t", typ, "-s", startargs)
cmd.Stdout = fout
cmd.Stderr = ferr
err = cmd.Start()
if err != nil {
log.LogFatalf(err)
return err
}
log.TraceInfo("master", "app start ", typ, ",", strconv.Itoa(int(appuid)))
atomic.AddInt32(&Load, 1)
context.waitGroup.Wrap(func() {
cmd.Wait()
ferr.Close()
fout.Close()
log.LogMessage(name, " is quit")
atomic.AddInt32(&Load, -1)
})
return nil
}
示例7: CreateRoleBack
func (d *DbBridge) CreateRoleBack(mailbox rpc.Mailbox, msg *rpc.Message) (errcode int32, reply *rpc.Message) {
r := server.NewMessageReader(msg)
errstr, err := r.ReadString()
if server.Check(err) {
return 0, nil
}
if errstr != "ok" {
server.Check(server.Error(nil, &mailbox, "Role.Error", share.ERROR_CREATE_ROLE_ERROR))
return 0, nil
}
player := App.Players.GetPlayer(mailbox.Id)
if player == nil {
log.LogError("player not found, id:", mailbox.Id)
//角色没有找到
return 0, nil
}
if player.State != STATE_LOGGED {
log.LogError("player state not logged")
return 0, nil
}
server.Check(d.getUserInfo(mailbox, player.Account))
return 0, nil
}
示例8: Start
func (c *Client) Start() {
log.LogMessage("client start:", c.id)
conn, err := net.Dial("tcp", "172.30.9.101:5391")
if err != nil {
log.LogError(err)
return
}
c.buf = make([]byte, 1024*16)
mid, data, err := util.ReadPkg(conn, c.buf)
if err != nil {
log.LogError(err)
log.LogError("quit client ", c.id)
return
}
l := &s2c.Login{}
err = ParseProto(mid, data, l)
if err != nil {
log.LogError(err)
log.LogError("quit client ", c.id)
return
}
conn.Close()
c.Login(l.GetHost(), l.GetPort())
}
示例9: GetBaseAndId
func (s *Session) GetBaseAndId(mailbox rpc.Mailbox, msg *rpc.Message) (errcode int32, reply *rpc.Message) {
r := server.NewMessageReader(msg)
user, err := r.ReadString()
if server.Check(err) {
return 0, nil
}
s.l.Lock()
defer s.l.Unlock()
s.serial++
if s.serial < 0 {
s.serial = 0
}
bases := server.GetAppIdsByType("base")
sort.Sort(sort.StringSlice(bases))
if len(bases) > 0 {
idx := s.serial % len(bases)
baseid := bases[idx]
s.id++
if base := server.GetAppByName(baseid); base != nil {
server.Check(base.Call(&mailbox, "Login.AddClient", user))
return 0, nil
}
log.LogError(server.ErrNotFoundApp)
return 0, nil
}
log.LogError(server.ErrNotFoundApp)
return 0, nil
}
示例10: Exchange
//交换子对象的位置
func (k *Kernel) Exchange(src Entityer, dest Entityer) bool {
if src == nil || dest == nil ||
src.GetParent() == nil ||
dest.GetParent() == nil ||
!src.GetParent().GetObjId().Equal(dest.GetParent().GetObjId()) {
log.LogError("parent not equal")
return false
}
parent := src.GetParent()
err := parent.SwapChild(src.GetIndex(), dest.GetIndex())
if err != nil {
log.LogError(err)
return false
}
if viewid := parent.GetExtraData("viewportid"); viewid != nil {
root := parent.GetRoot()
vp := k.FindViewport(root)
if vp != nil {
vp.ViewportNotifyExchange(viewid.(int32), int32(dest.GetIndex()), viewid.(int32), int32(src.GetIndex()))
}
}
return true
}
示例11: TeleportPlayerByBase
//当前服务器增加entity
func (t *TeleportHelper) TeleportPlayerByBase(sender rpc.Mailbox, msg *rpc.Message) (errcode int32, reply *rpc.Message) {
reply = CreateMessage(sender)
var playerinfo *datatype.EntityInfo
var args []interface{}
if err := ParseArgs(msg, &args); err != nil || len(args) < 1 {
log.LogError(err)
return share.ERR_ARGS_ERROR, reply
}
var ok bool
if playerinfo, ok = args[0].(*datatype.EntityInfo); !ok {
log.LogError("args parse error")
return share.ERR_ARGS_ERROR, reply
}
pl, err := core.CreateFromArchive(playerinfo, nil)
if err != nil {
log.LogError(err)
return share.ERR_FUNC_BEGIN + 1, reply
}
var params []interface{}
if len(args) > 1 {
params = args[1].([]interface{})
}
if !core.apper.OnTeleportFromBase(params, pl) {
core.Destroy(pl.GetObjId())
return share.ERR_REPLY_FAILED, reply
}
return share.ERR_REPLY_SUCCEED, reply
}
示例12: RemovePlayer
func (b *BaseProxy) RemovePlayer(mailbox rpc.Mailbox, reason int) error {
//同步数据
player := App.players.GetPlayer(mailbox)
if player == nil {
log.LogError("player not found")
}
player.Save(true)
var err error
if player.Entity.GetExtraData("saveData") == nil {
log.LogError("player save data is nil")
return err
}
err = server.MailTo(&App.MailBox,
&player.Base,
"Sync.SyncPlayer",
map[string]interface{}{
"mailbox": player.Mailbox,
"data": player.Entity.GetExtraData("saveData")},
)
player.Entity.RemoveExtraData("saveData")
return err
}
示例13: Load
func (s *GlobalData_Save) Load(eq ExecQueryer, dbId uint64, extfield string, extobjs ...interface{}) error {
sql, a := s.Query(dbId)
sql = fmt.Sprintf(sql, extfield)
r, err := eq.Query(sql, a...)
if err != nil {
log.LogError("load error:", err)
return err
}
defer r.Close()
if !r.Next() {
log.LogError("load error:", sql, a)
return ErrSqlRowError
}
args := []interface{}{&dbId, &s.Capacity, &s.ConfigId, &s.Name, &s.Test1, &s.Test2}
if extobjs != nil {
args = append(args, extobjs...)
}
if err = r.Scan(args...); err != nil {
log.LogError("load error:", err)
return err
}
if err = s.TestRec_r.Load(eq, dbId); err != nil {
log.LogError("load error:", err)
return err
}
return nil
}
示例14: ExecSql
func (this *Database) ExecSql(mailbox rpc.Mailbox, msg *rpc.Message) (errcode int32, reply *rpc.Message) {
var sqlstr string
var callback string
var callbackparams share.DBParams
if server.Check(server.ParseArgs(msg, &sqlstr, &callback, &callbackparams)) {
return 0, nil
}
sqlconn := db.sql
var r sql.Result
var err error
app := server.GetAppById(mailbox.App)
if app == nil {
log.LogError(server.ErrAppNotFound)
return 0, nil
}
if r, err = sqlconn.Exec(sqlstr); err != nil {
log.LogError("sql:", sqlstr)
server.Check(app.Call(nil, callback, callbackparams, 0, err.Error()))
return 0, nil
}
eff, _ := r.RowsAffected()
server.Check(app.Call(nil, callback, callbackparams, eff, ""))
return 0, nil
}
示例15: QuerySql
func (this *Database) QuerySql(mailbox rpc.Mailbox, msg *rpc.Message) (errcode int32, reply *rpc.Message) {
var sqlstr string
var callback string
var callbackparams share.DBParams
if server.Check(server.ParseArgs(msg, &sqlstr, &callback, &callbackparams)) {
return 0, nil
}
sqlconn := db.sql
var r *sql.Rows
var err error
app := server.GetAppById(mailbox.App)
if app == nil {
log.LogError(server.ErrAppNotFound)
return 0, nil
}
if r, err = sqlconn.Query(sqlstr); err != nil {
log.LogError(err)
return 0, nil
}
defer r.Close()
var cols []string
cols, err = r.Columns()
if err != nil {
server.Check(app.Call(nil, callback, callbackparams, []share.DBRow{share.DBRow{"error": []byte(err.Error())}}))
return 0, nil
}
result := make([]interface{}, len(cols))
for k := range result {
result[k] = new([]byte)
}
arrresult := make([]share.DBRow, 0, 100)
for r.Next() {
err = r.Scan(result...)
if err != nil {
log.LogError("sql:", sqlstr)
server.Check(app.Call(nil, callback, callbackparams, []share.DBRow{share.DBRow{"error": []byte(err.Error())}}))
return 0, nil
}
mapresult := make(share.DBRow, len(cols))
for k, v := range cols {
mapresult[v] = *result[k].(*[]byte)
}
arrresult = append(arrresult, mapresult)
if len(arrresult) == 100 {
break
}
}
server.Check(app.Call(nil, callback, callbackparams, arrresult))
return 0, nil
}