本文整理汇总了Golang中common/logger.Info函数的典型用法代码示例。如果您正苦于以下问题:Golang Info函数的具体用法?Golang Info怎么用?Golang Info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Info函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
logger.Info("start fight server")
var cfg config.SvrConfig
if err := config.ReadConfig(*svrConfigFile, &cfg); err != nil {
logger.Fatal("load config failed, error is: %v", err)
return
}
fightserver.StartServices(&cfg, fightServerId)
handler := func(s os.Signal, arg interface{}) {
logger.Info("handle signal: %v\n", s)
logger.Info("stop game server")
os.Exit(0)
}
handlerArray := []os.Signal{syscall.SIGINT,
syscall.SIGILL,
syscall.SIGFPE,
syscall.SIGSEGV,
syscall.SIGTERM,
syscall.SIGABRT}
common.WatchSystemSignal(&handlerArray, handler)
logger.Info("stop fight server")
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:28,代码来源:main.go
示例2: CreateServices
func CreateServices(authcfg config.AuthConfig) *AuthServer {
//初始化db
logger.Info("Init DB")
db.Init()
//初始化cache
var cacheCfg config.CacheConfig
if err := config.ReadConfig("etc/maincache.json", &cacheCfg); err != nil {
logger.Fatal("load config failed, error is: %v", err)
}
logger.Info("Init Cache %v", cacheCfg)
pAuthServices = &AuthServer{
maincache: db.NewCachePool(cacheCfg),
rpcServer: rpc.NewServer(),
exit: make(chan bool),
}
pAuthServices.rpcServer.Register(pAuthServices)
pAuthServices.rpcServer.ListenAndServe(authcfg.AuthHost, nil)
return pAuthServices
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:25,代码来源:AuthServer.go
示例3: register
func (server *Server) register(rcvr interface{}, name string, useName bool, rcvrFns ...interface{}) error {
server.mu.Lock()
if server.serviceMap == nil {
server.serviceMap = make(map[string]*service)
}
rcvrValue := reflect.ValueOf(rcvr)
sname := reflect.Indirect(rcvrValue).Type().Name()
if useName {
sname = name
}
if sname == "" {
logger.Fatal("rpc: no service name for type %v", reflect.ValueOf(rcvr).Interface())
}
if !isExported(sname) && !useName {
s := "rpc Register: type " + sname + " is not exported"
logger.Info(s)
server.mu.Lock()
return errors.New(s)
}
var s *service
if value, ok := server.serviceMap[sname]; ok {
server.mu.Lock()
s = value
logger.Warning("rpc: service already defined: %s", sname)
//return errors.New("rpc: service already defined: " + sname)
} else {
s = new(service)
s.typ = reflect.TypeOf(rcvr)
s.rcvr = reflect.ValueOf(rcvr)
s.name = sname
s.method = make(map[uint32]*methodType)
}
// Install the methods
// logger.Debug("Install the methods begine!")
s.method = server.suitableMethods(rcvr, s, s.typ, true, rcvrFns...)
if len(s.method) == 0 {
str := ""
// To help the user, see if a pointer receiver would work.
method := server.suitableMethods(rcvr, s, reflect.PtrTo(s.typ), false)
if len(method) != 0 {
str = "rpc.Register: type " + sname + " has no exported methods of suitable type (hint: pass a pointer to value of that type)"
} else {
str = "rpc.Register: type " + sname + " has no exported methods of suitable type"
}
logger.Info(str)
server.mu.Unlock()
return errors.New(str)
}
server.serviceMap[s.name] = s
server.mu.Unlock()
return nil
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:57,代码来源:Server.go
示例4: Init
func (self *FServerConnMgr) Init(connnector *server.Server, cfg config.SvrConfig) {
fsCount := len(cfg.FsHost)
self.Open(uint8(fsCount))
for i := 0; i < fsCount; i++ {
go func() {
defer func() {
if r := recover(); r != nil {
fmt.Printf("FServerConnMgr runtime error:", r)
debug.PrintStack()
}
}()
connId := self.GetNewConnId()
host := cfg.FsHost[connId]
for {
select {
case <-self.quit:
{
logger.Info("FServerConnMgr Goroutine Quit ----->")
return
}
default:
{
var err error
var fsConn net.Conn
for {
fsConn, err = net.Dial("tcp", host)
if err != nil {
//logger.Fatal("Connect FightServer Error :%s", err.Error())
} else {
break
}
}
logger.Info("Connect to FightServer : %s ok!!!!", host)
fsRpcConn := server.NewTCPSocketConn(connnector, fsConn, 1000, 0, 1)
fsRpcConn.SetResultServer("FightServer")
self.NewConn(fsRpcConn, connId)
connnector.ServeConn(fsRpcConn)
}
}
}
}()
}
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:54,代码来源:FsConnMgr.go
示例5: LA_CheckAccount
func (self *AuthServer) LA_CheckAccount(req *protobuf.LA_CheckAccount, ret *protobuf.AL_CheckAccountResult) error {
uid := common.GenUUID(req.GetAccount())
if len(req.GetUid()) > 0 {
if req.GetUid() != uid { //客户端伪造uid
(*ret).SetResult(protobuf.AL_CheckAccountResult_AUTH_FAILED)
return nil
}
}
account := &protobuf.AccountInfo{}
result, err := db.Query("AccountInfo", uid, account)
if err != nil {
(*ret).SetResult(protobuf.AL_CheckAccountResult_SERVERERROR)
return nil
}
if result == false { //用户注册
account.SetUid(uid)
account.SetAccount(req.GetAccount())
account.SetPassword(common.GenPassword(req.GetAccount(), req.GetPassword()))
account.SetLanguage(req.GetLanguage())
account.SetOption(req.GetOption())
account.SetSessionKey(common.GenSessionKey())
account.SetUdid(req.GetUdid())
account.SetCreateTime(uint32(time.Now().Unix()))
db.Write("AccountInfo", uid, account)
logger.Info("Auth AccountInfo create")
} else { //用户登陆
if !common.CheckPassword(account.GetPassword(), req.GetAccount(), req.GetPassword()) {
(*ret).SetResult(protobuf.AL_CheckAccountResult_AUTH_FAILED)
return nil
}
account.SetSessionKey(common.GenSessionKey()) //保存进缓存
db.Write("AccountInfo", uid, account)
logger.Info("Auth Account find")
}
self.maincache.Do("SET", "SessionKey_"+uid, []byte(account.GetSessionKey()))
(*ret).SetResult(protobuf.AL_CheckAccountResult_OK)
(*ret).SetSessionKey(account.GetSessionKey())
(*ret).SetUid(account.GetUid())
logger.Info("ComeInto AuthServer.Login %v, %v", req, ret)
return nil
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:53,代码来源:AuthServer.go
示例6: OnQuit
func (p *Player) OnQuit() {
logger.Info("OnQuit Begin")
//pConn
if p.conn != nil {
p.conn.Lock()
defer func() {
p.conn.Unlock()
logger.Info("OnQuit End")
}()
}
p.Save()
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:15,代码来源:Player.go
示例7: DBCreator
func DBCreator(cfg config.MySQLConfig) CreateDBFunc {
dns := fmt.Sprintf("%s:%[email protected](%s:%d)/%s?charset=%s", cfg.Uname, cfg.Pass, cfg.Host, cfg.Port, cfg.Dbname, cfg.Charset)
logger.Info("MySqlDNS: %s", dns)
return func() (db *sql.DB, dnsInfo string, err error) {
dnsInfo = dns
var retry uint8 = 0
for {
db, err = sql.Open("mysql", dns)
if err == nil {
break
}
logger.Error("Error on Create db: %s; try: %d/%d", err.Error(), retry, cfg.MaxRetry)
if retry >= cfg.MaxRetry {
return
}
retry++
}
return
}
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:25,代码来源:DbPool.go
示例8: Close
func (conn *ProtoBufConn) Close() (errret error) {
conn.lockForClose.Lock()
logger.Info("ProtoBufConn %d Close : %v", conn.id, errret)
if conn.is_closed {
conn.lockForClose.Unlock()
return nil
}
if err := conn.c.Close(); err != nil {
//再尝试一次
time.Sleep(10 * time.Millisecond)
if err := conn.c.Close(); err != nil {
conn.lockForClose.Unlock()
return err
}
}
conn.is_closed = true
if conn.t != nil {
conn.t.Stop()
}
conn.exit <- true
conn.lockForClose.Unlock()
return nil
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:32,代码来源:Conn.go
示例9: OnCheck
func (conn *ProtoBufConn) OnCheck() {
time_diff := uint32(time.Now().Unix() - conn.last_time)
if time_diff > conn.time_out<<1 {
logger.Info("Conn %d TimeOut: %d", conn.GetId(), time_diff)
conn.Close()
}
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:7,代码来源:Conn.go
示例10: WriteResult
func WriteResult(conn server.RpcConn, value interface{}) bool {
err := conn.WriteObj(value)
if err != nil {
logger.Info("WriteResult Error %s", err.Error())
return false
}
return true
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:8,代码来源:Connector.go
示例11: addBattle
func (self *FightServer) addBattle(b *Battle) {
logger.Info("Connector:addBattle %v, %v", b.GetBid(), b)
self.l.Lock()
defer self.l.Unlock()
//
self.battles[b.GetBid()] = b
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:9,代码来源:FightServer.go
示例12: delBattle
func (self *FightServer) delBattle(bid string) {
logger.Info("Connector:delBattle %v", bid)
_, exist := self.battles[bid]
if exist {
self.l.Lock()
delete(self.battles, bid)
self.l.Unlock()
}
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:10,代码来源:FightServer.go
示例13: addPlayer
//添加玩家到全局表中
func (self *Connector) addPlayer(connId uint64, p *Player) {
logger.Info("Connector:addPlayer %v, %v", connId, p.GetUid())
self.l.Lock()
defer self.l.Unlock()
//进入服务器全局表
self.players[connId] = p
self.playersbyid[p.GetUid()] = p
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:11,代码来源:Connector.go
示例14: GetWorkConn
func (self *FServerConnMgr) GetWorkConn() server.RpcConn {
self.poollock.Lock()
defer self.poollock.Unlock()
self.workindex++
if uint8(self.workindex) >= self.poolsize {
self.workindex = 0
}
logger.Info("FServerConnMgr GetWorkConn -----> %v", self.workindex)
return self.connpool[self.workindex]
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:11,代码来源:FsConnMgr.go
示例15: Quit
func (self *FServerConnMgr) Quit() {
self.poollock.Lock()
defer self.poollock.Unlock()
for i, v := range self.connpool {
logger.Info("ShutDown FServerConnMgr -----> %d", i)
v.Close()
self.quit <- true
}
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:11,代码来源:FsConnMgr.go
示例16: delPlayer
//销毁玩家
func (self *Connector) delPlayer(connId uint64) {
logger.Info("Connector:delPlayer %v", connId)
p, exist := self.players[connId]
if exist {
p.OnQuit()
self.l.Lock()
delete(self.players, connId)
delete(self.playersbyid, p.GetUid())
self.l.Unlock()
}
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:14,代码来源:Connector.go
示例17: 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
示例18: Register_lua_db_CachePool_newClass
func Register_lua_db_CachePool_newClass(L *lua.LState) int {
cfg := L.CheckString(2)
var cacheCfg config.CacheConfig
if err := config.ReadConfig(cfg, &cacheCfg); err != nil {
logger.Fatal("load config failed, error is: %v", err)
}
logger.Info("Init Cache %v", cacheCfg)
cache := db.NewCachePool(cacheCfg)
ud := L.NewUserData()
ud.Value = cache
L.SetMetatable(ud, L.GetTypeMetatable(luaCachePoolTypeName))
L.Push(ud)
return 1
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:14,代码来源:lua_db_CachePool_auto.go
示例19: wsServeConnHandler
func (server *Server) wsServeConnHandler(w http.ResponseWriter, r *http.Request) {
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
logger.Info("Upgrade:", err)
return
}
rpcConn := NewWebSocketConn(server, *conn, 4, 30, 2)
defer func() {
rpcConn.Close()
}()
server.ServeConn(rpcConn)
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:15,代码来源:Server.go
示例20: WatchSystemSignal
func WatchSystemSignal() {
callbackHandler := func(s os.Signal, arg interface{}) {
logger.Info("handle signal: %v\n", s)
logger.Info("stop game server")
os.Exit(0)
}
watchsingals := []os.Signal{syscall.SIGINT,
syscall.SIGILL,
syscall.SIGFPE,
syscall.SIGSEGV,
syscall.SIGTERM,
syscall.SIGABRT}
ss := signalSetNew()
for _, wathsingnal := range watchsingals {
ss.register(wathsingnal, callbackHandler)
}
for {
c := make(chan os.Signal)
var sigs []os.Signal
for sig := range ss.m {
sigs = append(sigs, sig)
}
signal.Notify(c)
sig := <-c
err := ss.handle(sig, nil)
if err != nil {
fmt.Printf("unknown signal received: %v\n", sig)
}
}
}
开发者ID:bodogbo,项目名称:OSG-Server-Go,代码行数:36,代码来源:common.go
注:本文中的common/logger.Info函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论