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


Golang log.LogMessage函数代码示例

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


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

示例1: work

func (a *Account) work(id int) {
	log.LogMessage("db work, id:", id)
	var start_time time.Time
	var delay time.Duration
	warninglvl := 50 * time.Millisecond
	for {
		select {
		case caller := <-a.queue[id]:
			log.LogMessage(caller.GetSrc(), " rpc call:", caller.GetMethod(), ", thread:", id)
			start_time = time.Now()
			err := caller.Call()
			if err != nil {
				log.LogError("rpc error:", err)
			}
			delay = time.Now().Sub(start_time)
			if delay > warninglvl {
				log.LogWarning("rpc call ", caller.GetMethod(), " delay:", delay.Nanoseconds()/1000000, "ms")
			}
			caller.Free()
			break
		default:
			if a.quit {
				return
			}
			time.Sleep(time.Millisecond)
		}
	}
}
开发者ID:mysll,项目名称:flynet,代码行数:28,代码来源:account.go

示例2: OnCreateGlobalData

//callback
func (gd *GlobalDataHelper) OnCreateGlobalData(msg *rpc.Message) {
	var appname string
	if err := ParseArgs(msg, &appname); err != nil {
		log.LogError(err)
		return
	}
	ret := GetReplyError(msg)

	client, exist := gd.globalclients[appname]
	if !exist {
		return
	}

	if ret == share.ERR_FUNC_BEGIN+1 {
		client.disable = false
		log.LogMessage(appname, " global data is disabled")
		return
	}

	if ret != share.ERR_REPLY_SUCCEED {

		client.errcount++
		client.status = STATUS_NONE
		return

	}

	client.status = STATUS_CREATED
	log.LogMessage("create global data to ", appname, " succeed")
}
开发者ID:mysll,项目名称:flynet,代码行数:31,代码来源:kernel_globaldata.go

示例3: Handle

//处理由客户端的发起远程调用
func (app *RemoteApp) Handle(src rpc.Mailbox, method string, args interface{}) error {
	app.Lock()
	defer app.Unlock()

	if app.Id == core.AppId {
		log.LogMessage("rpc inner handle:", method)
		return core.rpcServer.Call("C2S"+method, src, args)
	}

	if app.Conn == nil {

		if app.Conn == nil {
			conn, err := net.DialTimeout("tcp", fmt.Sprintf("%s:%d", app.Host, app.Port), time.Second)
			if err != nil {
				return err
			}
			app.Conn = conn
			app.RpcClient = rpc.NewClient(conn)
			log.LogMessage("rpc connected:", app.Name, ",", fmt.Sprintf("%s:%d", app.Host, app.Port))
		}
	}
	log.LogMessage("remote handle:", app.Name, "/", method)
	err := app.RpcClient.Call("C2S"+method, src, args)
	if err == rpc.ErrShutdown {
		log.LogError(err)
		app.Close()
	}
	return err
}
开发者ID:mysll,项目名称:flynet,代码行数:30,代码来源:remoteapp.go

示例4: 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)
		}
	}
}
开发者ID:mysll,项目名称:flynet,代码行数:33,代码来源:thread.go

示例5: Run

func (c *Coroutines) Run(job func(interface{}, interface{}) int, args interface{}, reply interface{}) {
	log.LogMessage("coroutine ", c.workid, " is started")
	ret := job(args, reply)
	c.result = ret
	c.reply = reply
	coroutinecomplete <- c.workid
	log.LogMessage("coroutine ", c.workid, " is complete")
}
开发者ID:mysll,项目名称:flynet,代码行数:8,代码来源:kernel_coroutine.go

示例6: GetArea

func (a *Areas) GetArea(mailbox rpc.Mailbox, id string) error {
	a.l.Lock()
	defer a.l.Unlock()

	log.LogMessage("GetArea")
	app := server.GetAppByName(mailbox.App)
	if app == nil {
		return server.ErrAppNotFound
	}

	if areainfo, exist := a.areas[id]; exist {
		if areainfo.Status == AREA_CREATED {
			return app.Call(&mailbox, "AreaBridge.GetAreaBak", areainfo.AppId)
		} else {
			a.pending[id].PushBack(mailbox)
			return nil
		}
	}

	a.lastareaid++
	appid := fmt.Sprintf("area_%d", a.lastareaid)
	data, err := share.CreateAppMsg("area",
		id,
		appid,
		fmt.Sprintf(`{ "id":"%s", "host":"127.0.0.1", "port":0, "areaid":"%s"}`,
			appid,
			id),
		App.Name,
	)
	if err != nil {
		log.LogError(err)
		return app.Call(&mailbox, "AreaBridge.GetAreaBak", "")
	}

	err = App.SendToMaster(data)
	if err != nil {
		log.LogError(err)
		return app.Call(&mailbox, "AreaBridge.GetAreaBak", "")
	}

	ar := &area{}
	ar.AppId = appid
	ar.Status = AREA_CREATING
	a.areas[id] = ar
	l := list.New()
	l.PushBack(mailbox)
	a.pending[id] = l

	log.LogMessage(a)
	return nil
}
开发者ID:mysll,项目名称:flynet,代码行数:51,代码来源:areas.go

示例7: UpdatePlayer

func (pl *PlayerList) UpdatePlayer(mailbox rpc.Mailbox, msg *rpc.Message) (errcode int32, reply *rpc.Message) {
	r := server.NewMessageReader(msg)
	account, err := r.ReadString()
	if server.Check(err) {
		return 0, nil
	}
	role_name, err := r.ReadString()
	if server.Check(err) {
		return 0, nil
	}
	base_id, err := r.ReadString()
	if server.Check(err) {
		return 0, nil
	}

	if base_id == "" {
		if acc, ok := pl.accounts[account]; ok {
			pl := acc.GetPlayInfo(role_name)
			if pl != nil {
				delete(acc.roles, account)
				log.LogMessage("remove ", account, ",", role_name)
			}
		}

		return 0, nil
	}

	if acc, ok := pl.accounts[account]; ok {
		p := acc.GetPlayInfo(role_name)
		if p != nil {
			log.LogMessage("update ", account, ",", role_name, " base:", base_id)
			p.BaseId = base_id
			return 0, nil
		}

		p = &PlayerInfo{role_name, base_id}
		acc.roles[role_name] = p
		log.LogMessage("add ", account, ",", role_name, " base:", base_id)
		return 0, nil
	}

	p := &PlayerInfo{role_name, base_id}
	acc := &AccountInfo{}
	acc.roles = make(map[string]*PlayerInfo, MAX_ROLES)
	acc.roles[role_name] = p
	pl.accounts[account] = acc
	log.LogMessage("add ", account, ",", role_name, " base:", base_id)
	return 0, nil
}
开发者ID:mysll,项目名称:flynet,代码行数:49,代码来源:playerlist.go

示例8: Register

//注册函数
func Register(name string, createfunc func() Entityer) {
	if _, dup := objects[name]; dup {
		panic("entity: Register called twice for object " + name)
	}
	log.LogMessage("register entity:", name)
	objects[name] = createfunc
}
开发者ID:mysll,项目名称:flynet,代码行数:8,代码来源:entityer.go

示例9: 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")
}
开发者ID:mysll,项目名称:flynet,代码行数:35,代码来源:kernel_globaldata.go

示例10: createAppBak

func (a *Areas) createAppBak(bak share.CreateAppBak) {
	a.l.Lock()
	defer a.l.Unlock()
	appid := ""
	if bak.Res == "ok" {
		a.areas[bak.Id].Status = AREA_CREATED
		appid = bak.AppId
	} else {
		delete(a.areas, bak.Id)
	}

	log.LogMessage(bak, a)

	p := a.pending[bak.Id]
	var next *list.Element
	for e := p.Front(); e != nil; e = next {
		next = e.Next()
		mailbox := e.Value.(rpc.Mailbox)
		p.Remove(e)
		app := server.GetAppByName(mailbox.App)
		if app == nil {
			continue
		}
		app.Call(&mailbox, "AreaBridge.GetAreaBak", appid)
	}

	delete(a.pending, bak.Id)
}
开发者ID:mysll,项目名称:flynet,代码行数:28,代码来源:areas.go

示例11: 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())
}
开发者ID:mysll,项目名称:flynet,代码行数:28,代码来源:client.go

示例12: AddObject

func (this *cell) AddObject(obj Entityer) error {
	id := obj.GetObjId()
	if _, ok := this.Objects[obj.ObjType()]; !ok {
		this.Objects[obj.ObjType()] = make(map[int32]Entityer, 256)
	}

	if _, dup := this.Objects[obj.ObjType()][id.Index]; dup {
		return errors.New("object already added")
	}

	this.Objects[obj.ObjType()][id.Index] = obj
	if obj.ObjType() == PLAYER {
		App.EntryScene(obj)
		this.enterScene(obj)
		App.baseProxy.entryScene(this.scene, obj)
		App.EnterScene(obj)
		log.LogMessage("add player:", obj.GetObjId())
		this.playernum++
		this.livetime = -1
	} else {
		this.enterScene(obj)
	}

	return nil
}
开发者ID:mysll,项目名称:flynet,代码行数:25,代码来源:cell.go

示例13: 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
}
开发者ID:mysll,项目名称:flynet,代码行数:34,代码来源:start_window.go

示例14: Do

func (a *Account) Do() {
	log.LogMessage("start db thread, total:", a.pools)
	for i := 0; i < a.pools; i++ {
		id := i
		db.wg.Wrap(func() { a.work(id) })
	}
}
开发者ID:mysll,项目名称:flynet,代码行数:7,代码来源:account.go

示例15: UseDB

/*
选择数据库
*/
func (conn *MySql) UseDB(db string) (err error) {
	if _, err = conn.Exec(fmt.Sprintf("use `%s`", db)); err != nil {
		return err
	}
	log.LogMessage("use db:", db)
	return
}
开发者ID:mysll,项目名称:flynet,代码行数:10,代码来源:mysql.go


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