本文整理汇总了Golang中common/logger.Info函数的典型用法代码示例。如果您正苦于以下问题:Golang Info函数的具体用法?Golang Info怎么用?Golang Info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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")
}
示例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
}
示例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
}
示例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)
}
}
}
}()
}
}
示例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
}
示例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()
}
示例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
}
}
示例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
}
示例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()
}
}
示例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
}
示例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
}
示例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()
}
}
示例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
}
示例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]
}
示例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
}
}