本文整理匯總了Golang中common/logger.Debug函數的典型用法代碼示例。如果您正苦於以下問題:Golang Debug函數的具體用法?Golang Debug怎麽用?Golang Debug使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Debug函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ReadRequest
func (conn *ProtoBufConn) ReadRequest(req *protobuf.Packet) error {
conn.c.SetReadDeadline(time.Now().Add(ConnReadTimeOut))
dst, err := conn.c.ReadMessage()
if err != nil {
logger.Debug("ReadRequest Read binary Err: %v", err)
return err
}
//dst, err := snappy.Decode(nil, dstBuffer.Bytes())
if err != nil {
logger.Debug("ReadRequest Decode Err: %v", err)
return err
}
conn.last_time = time.Now().Unix()
//logger.Info("ReadRequest dst: %v", dst)
err = proto.Unmarshal(dst, req)
conn.msg_id = req.GetId()
return err
}
示例2: ApplyProtocol
func (server *Server) ApplyProtocol(protocal map[string]int32) {
logger.Debug("ApplyProtocol")
for key, value := range protocal {
cmd := key[1:len(key)]
server.protocol[cmd] = uint32(value)
}
for key, value := range server.protocol {
logger.Debug("ApplyProtocol %s, %d", key, value)
}
}
示例3: wsServeConnHandler
func wsServeConnHandler(w http.ResponseWriter, r *http.Request) {
err := r.ParseForm()
if err != nil {
fmt.Fprintln(w, "rpc: error")
return
}
logger.Debug("wsServeConnHandler : %v", r.FormValue("method"))
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
logger.Info("Upgrade:", err.Error())
conn, bufrw, err := w.(http.Hijacker).Hijack()
if err != nil {
logger.Debug("rpc hijacking %v : %v", r.RemoteAddr, err.Error())
return
} else {
httpConn := server.NewTCPSocketConn(pConnector.rpcServer, conn, 1, 1, 1)
logger.Debug("rpc hijacking %v : %v", r.RemoteAddr, r.FormValue("method"))
fmt.Fprintln(w, "rpc: hello")
buf := make([]byte, 10)
for i := 0; i < len(buf); i++ {
buf[i] = byte(i)
}
_, err = bufrw.Write(buf)
if err == nil {
err = bufrw.Flush()
}
if err != nil {
fmt.Printf("ResponseError: %s\\n", err)
} else {
fmt.Println("Bye, Jack!")
}
logger.Debug("httpConn WriteObj %v", httpConn.GetRemoteIp())
}
return
}
rpcConn := server.NewWebSocketConn(pConnector.rpcServer, *conn, 128, 45, 2)
defer func() {
rpcConn.Close() // 客戶端退出減去計數
}()
pConnector.rpcServer.ServeConn(rpcConn)
}
示例4: CheckSessionKey
func CheckSessionKey(skey string) bool {
if len(skey) != 70 {
return false
}
b := make([]uint32, 5)
var s string
guid := skey[:36]
_, err := fmt.Sscanf(skey, "%x-%x-%x-%x-%x--%s", &b[0], &b[1], &b[2], &b[3], &b[4], &s)
if err != nil {
logger.Debug("err : %v", err.Error())
return false
}
info1 := make([]byte, 4)
binary.BigEndian.PutUint32(info1, b[0])
info2 := make([]byte, 4)
binary.BigEndian.PutUint16(info2[:2], uint16(b[1]))
binary.BigEndian.PutUint16(info2[2:], uint16(b[2]))
c, _ := rc4.NewCipher([]byte{0x0c, info1[2], info1[3], info1[0]})
tmp := make([]byte, 4)
c.XORKeyStream(tmp, info1)
if binary.BigEndian.Uint32(tmp) != b[3] {
return false
}
c.XORKeyStream(tmp, info2)
if binary.BigEndian.Uint32(tmp) != b[4] {
return false
}
h := md5.New()
io.WriteString(h, guid)
io.WriteString(h, MD5key)
if s != fmt.Sprintf("%x", h.Sum(nil)) {
logger.Debug("%s, %x", guid, h.Sum(nil))
return false
}
return true
}
示例5: StartBattle
func (self *FightServer) StartBattle(conn server.RpcConn, player protobuf.PlayerBaseInfo) error {
logger.Debug("StartBattle")
id := common.GenUUID(fmt.Sprintf("%d", atomic.AddUint64(&self.id, 1)))
base := &protobuf.BattleInfo{}
base.SetBid(id)
partners := make([]*protobuf.CreatureBaseInfo, 0, 10)
mosters := make([]*protobuf.CreatureBaseInfo, 0, 10)
partners = append(partners, ConvertPlayerToCreature(&player))
mosters = append(mosters, RandomCreature("1"), RandomCreature("2"), RandomCreature("3"), RandomCreature("4"), RandomCreature("5"))
base.SetPartner(partners)
base.SetEnemy(mosters)
base.SetAttackunits(make([]*protobuf.AttackInfo, 0, 10))
base.SetSpells(make([]*protobuf.SpellInfo, 0, 10))
b := &Battle{BattleInfo: base}
//WriteResult(conn, base)
notify := &protobuf.NotifyBattleStart{}
notify.SetBid(base.GetBid())
notify.SetPartner(partners)
notify.SetEnemy(mosters)
WriteResult(conn, notify)
self.addBattle(b)
return nil
}
示例6: Register_lua_db
func Register_lua_db(L *lua.LState) {
logger.Debug("Register_lua_db")
DefaultScript.RegisterGlobalFunction(luaDBInitFuncName, Register_lua_db_DBInit)
DefaultScript.RegisterGlobalFunction(luaDBQueryFuncName, Register_lua_db_DBQuery)
DefaultScript.RegisterGlobalFunction(luaDBWriteFuncName, Register_lua_db_DBWrite)
DefaultScript.RegisterGlobalFunction(luaDBDeleteFuncName, Register_lua_db_DBDelete)
}
示例7: Register_lua_common
func Register_lua_common(L *lua.LState) {
logger.Debug("Register_lua_common")
DefaultScript.RegisterGlobalFunction(luaWatchSystemSignalFuncName, Register_lua_common_WatchSystemSignal)
DefaultScript.RegisterGlobalFunction(luaWriteObjFuncName, Register_lua_common_WriteObj)
DefaultScript.RegisterGlobalFunction(luaSetIntervalFuncName, Register_lua_common_SetInterval)
DefaultScript.RegisterGlobalFunction(luaClearIntervalFuncName, Register_lua_common_ClearInterval)
}
示例8: Register_lua_json
func Register_lua_json(L *lua.LState) {
logger.Debug("Register_lua_json")
js := &Json{}
mt := DefaultScript.RegisterGlobalClassBegin(luaJsonTypeName, js)
DefaultScript.RegisterGlobalClassFunction(mt, "Decode", L.NewFunction(apiDecode))
DefaultScript.RegisterGlobalClassFunction(mt, "Encode", L.NewFunction(apiEncode))
DefaultScript.RegisterGlobalClassEnd(luaJsonTypeName)
}
示例9: CalculateBattleResult
func (self *FightServer) CalculateBattleResult(conn server.RpcConn, queue protobuf.BattleAttackQueue) error {
logger.Debug("CalculateBattleResult")
_, exist := self.battles[queue.GetBid()]
if !exist {
return nil
}
attackunits := self.battles[queue.GetBid()].GetAttackunits()
for _, att := range queue.GetAttackunits() {
attackunits = append(attackunits, att)
}
spells := self.battles[queue.GetBid()].GetSpells()
for _, att := range queue.GetSpells() {
spells = append(spells, att)
}
self.battles[queue.GetBid()].SetAttackunits(attackunits)
self.battles[queue.GetBid()].SetSpells(spells)
WriteResult(conn, self.battles[queue.GetBid()].BattleInfo)
end := true
for _, p := range self.battles[queue.GetBid()].GetPartner() {
stat := p.GetStat()
if stat.GetHP() > 0 {
end = false
}
}
var exp uint32
exp = 0
if !end {
exp = 100
for _, e := range self.battles[queue.GetBid()].GetEnemy() {
stat := e.GetStat()
if stat.GetHP() > 0 {
end = false
}
}
}
if end {
for _, p := range self.battles[queue.GetBid()].GetPartner() {
notify := &protobuf.NotifyBattleEnd{}
notify.SetPlayerlid(p.GetUid())
notify.SetExp(exp)
WriteResult(conn, notify)
}
}
return nil
}
示例10: ApplyProtocol
func (conn *ProtoBufConn) ApplyProtocol(protocal map[string]int32) {
logger.Debug("ApplyProtocol")
for key, value := range protocal {
protocalMethod := strings.Split(key, "_")
if len(protocalMethod) != 2 {
logger.Error("rpc: ApplyProtocol ill-formed: %v , no '_' for split key" + key)
}
conn.protocol[protocalMethod[1]] = uint32(value)
}
}
示例11: Register_lua_rpc_RpcServer
func Register_lua_rpc_RpcServer(L *lua.LState) {
logger.Debug("Register_server_%s", luaRpcServerTypeName)
svc := &rpc.Server{}
mt := DefaultScript.RegisterGlobalClassBegin(luaRpcServerTypeName, svc)
DefaultScript.RegisterGlobalClassFunction(mt, "new", L.NewFunction(Register_lua_rpc_RpcServer_newClass))
DefaultScript.RegisterGlobalClassFunction(mt, "__create", L.NewFunction(Register_lua_rpc_RpcServer_newClass))
DefaultScript.RegisterGlobalClassFunction(mt, "__cname", lua.LString(luaRpcServerTypeName))
DefaultScript.RegisterGlobalClassFunction(mt, "__ctype", lua.LNumber(1))
DefaultScript.RegisterGlobalClassFunction(mt, "__index", L.SetFuncs(L.NewTable(), indexRpcServerMethods))
DefaultScript.RegisterGlobalClassEnd(luaRpcServerTypeName)
}
示例12: Register_lua_db_CachePool
func Register_lua_db_CachePool(L *lua.LState) {
logger.Debug("Register_lua_common")
cache := db.CachePool{}
mt := DefaultScript.RegisterGlobalClassBegin(luaCachePoolTypeName, cache)
DefaultScript.RegisterGlobalClassFunction(mt, "new", L.NewFunction(Register_lua_db_CachePool_newClass))
DefaultScript.RegisterGlobalClassFunction(mt, "__create", L.NewFunction(Register_lua_db_CachePool_newClass))
DefaultScript.RegisterGlobalClassFunction(mt, "__cname", lua.LString(luaCachePoolTypeName))
DefaultScript.RegisterGlobalClassFunction(mt, "__ctype", lua.LNumber(1))
DefaultScript.RegisterGlobalClassFunction(mt, "__index", L.SetFuncs(L.NewTable(), indexCachePoolMethods))
DefaultScript.RegisterGlobalClassEnd(luaCachePoolTypeName)
}
示例13: Register_lua_server_RpcConn
func Register_lua_server_RpcConn(L *lua.LState) {
logger.Debug("Register_server_%s", luaRpcConnTypeName)
conn := &server.ProtoBufConn{}
mt := DefaultScript.RegisterGlobalClassBegin(luaRpcConnTypeName, conn)
DefaultScript.RegisterGlobalClassFunction(mt, "new", L.NewFunction(Register_lua_server_RpcConn_newClass))
DefaultScript.RegisterGlobalClassFunction(mt, "__create", L.NewFunction(Register_lua_server_RpcConn_newClass))
DefaultScript.RegisterGlobalClassFunction(mt, "__cname", lua.LString(luaRpcConnTypeName))
DefaultScript.RegisterGlobalClassFunction(mt, "__ctype", lua.LNumber(1))
DefaultScript.RegisterGlobalClassFunction(mt, "__index", L.SetFuncs(L.NewTable(), indexRpcConnMethods))
DefaultScript.RegisterGlobalClassEnd(luaRpcConnTypeName)
}
示例14: RegisterOsgModule
func RegisterOsgModule(L *lua.LState) int {
logger.Debug("osg module Loader")
Register_lua_json(L)
Register_lua_common(L)
Register_lua_db(L)
Register_lua_db_CachePool(L)
Register_lua_rpc_RpcClient(L)
Register_lua_rpc_RpcServer(L)
Register_lua_server_RpcConn(L)
Register_lua_server_Server(L)
return 0
}
示例15: RegisterProtobufModule
func RegisterProtobufModule(L *lua.LState) int {
logger.Debug("protobuf module Loader")
DefaultScript.ExecuteScriptFile("script/protobuf/descriptor.lua")
DefaultScript.ExecuteScriptFile("script/protobuf/text_format.lua")
DefaultScript.ExecuteScriptFile("script/protobuf/containers.lua")
DefaultScript.ExecuteScriptFile("script/protobuf/listener.lua")
DefaultScript.ExecuteScriptFile("script/protobuf/type_checkers.lua")
DefaultScript.ExecuteScriptFile("script/protobuf/wire_format.lua")
DefaultScript.ExecuteScriptFile("script/protobuf/encoder.lua")
DefaultScript.ExecuteScriptFile("script/protobuf/decoder.lua")
DefaultScript.ExecuteScriptFile("script/protobuf/protobuf.lua")
return 0
}