本文整理汇总了Golang中common/logger.Debug函数的典型用法代码示例。如果您正苦于以下问题:Golang Debug函数的具体用法?Golang Debug怎么用?Golang Debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Debug函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:25,代码来源:Conn.go
示例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)
}
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:10,代码来源:Server.go
示例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)
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:51,代码来源:Connector.go
示例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
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:50,代码来源:common.go
示例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
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:28,代码来源:FightServer.go
示例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)
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:7,代码来源:lua_db_auto.go
示例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)
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:7,代码来源:lua_common_auto.go
示例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)
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:8,代码来源:lua_json_auto.go
示例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
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:57,代码来源:FightServer.go
示例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)
}
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:10,代码来源:Conn.go
示例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)
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:11,代码来源:lua_rpc_RpcServer_auto.go
示例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)
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:11,代码来源:lua_db_CachePool_auto.go
示例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)
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:11,代码来源:lua_server_RpcConn_auto.go
示例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
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:12,代码来源:lua_osg_auto.go
示例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
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:13,代码来源:lua_pb_auto.go
示例16: ReadMessage
func (c Conn) ReadMessage() ([]byte, error) {
var size uint32
switch c.client_type {
case 1:
err := binary.Read(c.tcp_socket, binary.LittleEndian, &size)
if err != nil {
logger.Debug("ReadMessage err 1: %v", err.Error())
return nil, err
}
buf := make([]byte, size)
c.SetReadDeadline(time.Now().Add(ConnReadTimeOut))
_, err = io.ReadFull(c.tcp_socket, buf)
if err != nil {
logger.Debug("ReadMessage err 2: %v", err.Error())
return nil, err
}
return buf, err
case 2:
_, buf, err := c.web_socket.ReadMessage()
dstBuffer := bytes.NewBuffer(buf)
c.SetReadDeadline(time.Now().Add(ConnReadTimeOut))
err = binary.Read(dstBuffer, binary.LittleEndian, &size)
return dstBuffer.Bytes(), err
default:
return nil, errors.New("ProtoBufConn: err client_type unknown")
}
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:38,代码来源:Conn.go
示例17: RegisterFromLua
func (server *Server) RegisterFromLua(rcvr *lua.LTable, rcvrFns *lua.LTable) error {
logger.Debug("RegisterFromLua")
sname := ""
rcvr.ForEach(func(key, value lua.LValue) {
switch k := key.(type) {
case lua.LString:
if string(k) == "name" {
sname = value.String()
}
}
})
return server.register(rcvr, sname, sname != "", rcvrFns)
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:14,代码来源:Server.go
示例18: Register_lua_rpc_RpcClient_Call
func Register_lua_rpc_RpcClient_Call(L *lua.LState) int {
ud := L.CheckUserData(1)
method := L.CheckString(2)
args := L.CheckString(3)
if L.GetTop() > 4 {
argstyp := L.CheckString(5)
reptyp := L.CheckString(6)
//logger.Debug("Register_lua_rpc_RpcClient_Call(%v,%v,%v,%v,%v,%v)", ud, method, args, "", argstyp, reptyp)
if v, ok := ud.Value.(*rpc.Client); ok {
typArgs := DefaultScript.GetPbType(argstyp)
typRep := DefaultScript.GetPbType(reptyp)
valueArgs := reflect.New(typArgs)
valueRep := reflect.New(typRep)
if valueRep.Interface() != nil && valueArgs.Interface() != nil {
if value, ok := (valueArgs.Interface()).(proto.Message); ok {
proto.Unmarshal([]byte(args), value)
repMsg := valueRep.Interface()
v.Call(method, value, repMsg)
rep, err := proto.Marshal(repMsg.(proto.Message))
if err != nil {
logger.Debug("Register_lua_rpc_RpcClient_Call : Marshal Error %v ", valueRep.Interface())
return 0
}
L.Replace(4, lua.LString(string(rep)))
L.Push(lua.LString(string(rep)))
//logger.Debug("Register_lua_rpc_RpcClient_Call (%d): rep %v ", L.GetTop(), string(rep))
return 1
} else {
logger.Error("Register_lua_rpc_RpcClient_Call Error type : %v", valueArgs.Interface())
}
} else {
logger.Error("Register_lua_rpc_RpcClient_Call Error : valueArgs %v, valueRep %v", valueArgs.Interface(), valueRep.Interface())
}
}
} else {
if v, ok := ud.Value.(*rpc.Client); ok {
req := []byte(args)
rep := []byte("")
v.Call(method, &req, &rep)
L.Replace(4, lua.LString(string(rep)))
L.Push(lua.LString(string(rep)))
//logger.Debug("Register_lua_rpc_RpcClient_Call (%d): rep %v ", L.GetTop(), string(rep))
return 1
}
}
return 0
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:48,代码来源:lua_rpc_RpcClient_auto.go
示例19: Init
func Init() {
//base
var dbCfg config.DBConfig
if err := config.ReadConfig("etc/dbBase.json", &dbCfg); err != nil {
logger.Fatal("%v", err)
}
aHosts := make([]string, 0)
aHosts = append(aHosts, dbCfg.DBHost)
pPollBase = rpc.CreateClientPool(aHosts)
if pPollBase == nil {
logger.Fatal("create failed")
}
logger.Debug("Init DBClient : %v ", dbCfg.DBHost)
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:16,代码来源:dbclient.go
示例20: Register_lua_db_DBQuery
func Register_lua_db_DBQuery(L *lua.LState) int {
tablename := L.CheckString(1)
key := L.CheckString(2)
buf := []byte("")
exist, err := db.QueryBinary(tablename, key, &buf)
if err == nil {
L.Push(lua.LString(string(buf)))
L.Push(lua.LBool(exist))
L.Push(lua.LString(""))
} else {
logger.Debug("DBQuery Error %v, %v, %v", buf, exist, err)
L.Push(lua.LString(""))
L.Push(lua.LBool(exist))
L.Push(lua.LString(err.Error()))
}
return 3 //value exist err
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:17,代码来源:lua_db_auto.go
注:本文中的common/logger.Debug函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论