本文整理汇总了Golang中github.com/playnb/mustang/log.Trace函数的典型用法代码示例。如果您正苦于以下问题:Golang Trace函数的具体用法?Golang Trace怎么用?Golang Trace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Trace函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: LoadConfig
func LoadConfig() {
config_file := flag.String("config", "", "Use -config <filesource>")
config_url := flag.String("config_url", "", "Use -config_url <filesource>")
flag.Parse()
utils.GetParentDirectory(utils.GetCurrentDirectory())
if len(*config_file) > 1 {
fmt.Println("读取配置文件: " + *config_file)
utils.LoadJsonFile(*config_file, C)
} else if len(*config_url) > 1 {
fmt.Println("读取配置文件: " + *config_url)
utils.LoadJsonURL(*config_url, C)
}
log.Release = (C.Release != 0)
Release = (C.Release != 0)
if Release {
log.Trace("Release模式运行")
} else {
log.Trace("Debug模式运行")
}
//一些特殊值
if C.LoginTimeOut <= 1 {
C.LoginTimeOut = 3
}
log.Debug("%v", C)
}
开发者ID:playnb,项目名称:mustang,代码行数:28,代码来源:conf.go
示例2: clientCall
func clientCall(min int32) {
startTime := currentTimeMillis()
transportFactory := thrift.NewTFramedTransportFactory(thrift.NewTTransportFactory())
protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
transport, err := thrift.NewTSocket(NetworkAddr)
for err != nil {
transport, err = thrift.NewTSocket(NetworkAddr)
if err != nil {
log.Error("error resolving address:", err)
}
time.Sleep(1 * time.Second)
}
useTransport := transportFactory.GetTransport(transport)
client := demo.NewRpcServiceClientFactory(useTransport, protocolFactory)
if err := transport.Open(); err != nil {
log.Error("Error opening socket to 127.0.0.1:19090", " ", err)
return
}
defer transport.Close()
for i := min; i < min+3; i++ {
r1, e1 := client.Add(i, i+1)
log.Trace("%d %s %v %v", i, "Call->", r1, e1)
}
endTime := currentTimeMillis()
log.Trace("Program exit. time->", endTime, startTime, (endTime - startTime))
}
开发者ID:playnb,项目名称:grasslands,代码行数:30,代码来源:test_thrift.go
示例3: Login
//登录SuperService
func (service *superRpc) Login(req *msg.LoginRequst, res *msg.LoginRespose) error {
log.Trace("[SUPER] %s(%s) 的连接到来", utils.GetServiceName(int(req.GetServiceType())), string(req.GetServiceIp()))
res.ServiceType = proto.Uint32(req.GetServiceType())
res.ServiceId = proto.Uint64(100)
res.ServiceIp = proto.String(req.GetServiceIp())
res.RetCode = proto.Uint32(1)
res.ExterPort = proto.Uint32(300)
log.Trace("[SUPER] 返回 %s 服务器ID %d", utils.GetServiceName(int(res.GetServiceType())), res.GetServiceId())
return nil
}
开发者ID:playnb,项目名称:grasslands,代码行数:11,代码来源:superrpc.go
示例4: check_valid
//检查参数合法性
func (server *TCPServer) check_valid() {
if server.MaxConnNum <= 0 {
server.MaxConnNum = 100
log.Trace("invalid MaxConnNum, reset to %v", server.MaxConnNum)
}
if server.PendingWriteNum <= 0 {
server.PendingWriteNum = 100
log.Trace("invalid PendingWriteNum, reset to %v", server.PendingWriteNum)
}
if server.NewAgent == nil {
log.Fatal("NewAgent must not be nil")
}
}
开发者ID:playnb,项目名称:mustang,代码行数:14,代码来源:tcp_server.go
示例5: RefreshAccessToken
//获取微信服务器的Token
func RefreshAccessToken(loop bool) {
type wxJsonToken struct {
WeiXinError
AccessToken string `json:"access_token"`
ExpiresIn int `json:"expires_in"`
}
wxToken := new(WeiXinAccessToken)
if !wxToken.Load(wxProfile.AppID) {
wxToken.ExpireIn = 0
wxProfile.AccessToken = ""
} else {
wxProfile.AccessToken = wxToken.AccessToken
log.Trace("加载数据库微信Accesstoken: %s", wxProfile.AccessToken)
}
for loop {
newSec := time.Now().UnixNano() / time.Second.Nanoseconds()
for newSec < wxToken.ExpireIn {
time.Sleep(time.Second)
newSec = time.Now().UnixNano() / time.Second.Nanoseconds()
}
wxProfile.AccessToken = ""
log.Trace("微信Accesstoken过期,重新获取Token")
url := "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET"
url = strings.Replace(url, "APPID", wxProfile.AppID, -1)
url = strings.Replace(url, "APPSECRET", wxProfile.AppSecret, -1)
//log.Debug(url)
res, err := http.Get(url)
if err != nil {
log.Error("获取Token失败 %v", err)
}
result, err := ioutil.ReadAll(res.Body)
res.Body.Close()
if err != nil {
log.Error("解析Token失败 %v", err)
}
log.Debug(string(result))
var jsonData wxJsonToken
if err := json.Unmarshal(result, &jsonData); err == nil {
wxProfile.AccessToken = jsonData.AccessToken
log.Trace("收到Token: %s", wxProfile.AccessToken)
wxToken.AccessToken = jsonData.AccessToken
wxToken.ExpireIn = newSec + int64(jsonData.ExpiresIn) - 60*10
wxToken.Save()
} else {
log.Error(err.Error())
}
}
}
开发者ID:playnb,项目名称:mustang,代码行数:52,代码来源:accestoken.go
示例6: RefreshJsApiTicket
//刷新JsApiTicket
func RefreshJsApiTicket(loop bool) {
type wxJsonToken struct {
WeiXinError
JsApiTicket string `json:"ticket"`
ExpiresIn int `json:"expires_in"`
}
wxTicket := new(WeiXinJsApiTicket)
if !wxTicket.Load(wxProfile.AppID) {
wxTicket.ExpireIn = 0
} else {
wxProfile.JsApiTicket = wxTicket.JsApiTicket
log.Trace("加载数据库微信JsApiTicket: %s", wxProfile.JsApiTicket)
}
for loop {
newSec := time.Now().UnixNano() / time.Second.Nanoseconds()
for newSec < wxTicket.ExpireIn || len(wxProfile.AccessToken) == 0 {
time.Sleep(time.Second)
newSec = time.Now().UnixNano() / time.Second.Nanoseconds()
}
log.Trace("微信JsApiTicket过期,重新获取JsApiTicket")
url := "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=jsapi"
url = strings.Replace(url, "ACCESS_TOKEN", wxProfile.AccessToken, -1)
//log.Debug(url)
res, err := http.Get(url)
if err != nil {
log.Error("获取JsApiTicket失败 %v", err)
}
result, err := ioutil.ReadAll(res.Body)
res.Body.Close()
if err != nil {
log.Error("解析JsApiTicket失败 %v", err)
}
log.Debug(string(result))
var jsonData wxJsonToken
if err := json.Unmarshal(result, &jsonData); err == nil {
wxProfile.JsApiTicket = wxTicket.JsApiTicket
log.Trace("收到JsApiTicket: %s", wxProfile.AccessToken)
wxTicket.JsApiTicket = jsonData.JsApiTicket
wxTicket.ExpireIn = newSec + int64(jsonData.ExpiresIn) - 60*10
wxTicket.Save()
} else {
log.Error(err.Error())
}
}
}
开发者ID:playnb,项目名称:mustang,代码行数:49,代码来源:accestoken.go
示例7: handleStatic
func handleStatic(w http.ResponseWriter, r *http.Request) {
path := r.URL.Path
index := strings.LastIndex(path, ".")
if index != -1 {
request_type := path[index:]
switch request_type {
case ".css":
w.Header().Set("content-type", "text/css")
case ".js":
w.Header().Set("content-type", "text/javascript")
default:
}
}
path = baseDir + path
log.Trace("获取静态文件: %s", path)
fin, err := os.Open(path)
defer fin.Close()
if err != nil {
log.Error("static resource: %v", err)
w.WriteHeader(505)
} else {
fd, _ := ioutil.ReadAll(fin)
w.Write(fd)
}
}
开发者ID:playnb,项目名称:grasslands,代码行数:25,代码来源:Main.go
示例8: StartService
func (g *gateService) StartService(superRpcAddr string) {
superClient, err := msg.DialSuperService("tcp", superRpcAddr)
maxRetry := 10
for err != nil {
if maxRetry > 0 {
maxRetry = maxRetry - 1
} else {
log.Fatal("连接SuperService失败")
return
}
log.Error("连接SuperService失败,1秒后重试 :%v", err)
time.Sleep(time.Second * 1)
superClient, err = msg.DialSuperService("tcp", superRpcAddr)
}
res, err := superClient.Login(&msg.LoginRequst{ServiceIp: proto.String("127.0.0.1")})
if err != nil {
log.Fatal("[GATE] 登录SuperService失败 rpc:%s", superRpcAddr)
return
}
g.SuperClient = superClient
g.gateway.Addr = string(res.GetServiceIp()) + ":" + strconv.Itoa(int(res.GetExterPort()))
g.gateway.HTTPTimeout = 3 * 60
g.gateway.MaxConnNum = 1000
g.gateway.PendingWriteNum = 1000
g.gateway.ProtobufProcessor = g.processor
log.Trace("[GATE] 网关服务在%s:%d 启动", string(res.GetServiceIp()), res.GetExterPort())
g.gateway.Run(utils.CloseSig)
}
开发者ID:playnb,项目名称:grasslands,代码行数:28,代码来源:gate.go
示例9: checkValid
//配置合理性检查
func (server *WSServer) checkValid() {
if server.MaxConnNum <= 0 {
server.MaxConnNum = 100
log.Trace("invalid MaxConnNum, reset to %v", server.MaxConnNum)
}
if server.PendingWriteNum <= 0 {
server.PendingWriteNum = 100
log.Trace("invalid PendingWriteNum, reset to %v", server.PendingWriteNum)
}
if server.NewAgent == nil {
log.Fatal("NewAgent must not be nil")
}
if server.HTTPTimeout <= 0 {
server.HTTPTimeout = 10 * time.Second
log.Trace("invalid HTTPTimeout, reset to %v", server.HTTPTimeout)
}
}
开发者ID:playnb,项目名称:mustang,代码行数:18,代码来源:websocket_server.go
示例10: Echo
func (t *EchoService) Echo(args *Msg.EchoRequest, reply *Msg.EchoResponse) error {
//t.Lock()
//defer t.Unlock()
reply.Msg = proto.String("Echo:" + args.GetMsg())
t.count++
log.Trace(strconv.Itoa(int(t.count)))
time.Sleep(time.Second * 4)
return nil
}
开发者ID:playnb,项目名称:grasslands,代码行数:9,代码来源:test_protorpc.go
示例11: GetAuthUrlBySina
//获取SIna授权URL
func (service *superRpc) GetAuthUrlBySina(req *msg.OAuth2Request, res *msg.OAuth2Url) error {
auth_sid := utils.GenEasyNextId(utils.SnowflakeSystemWork, utils.SnowflakeCatalogAuth)
auth_ch := make(chan *auth.AuthUserData)
service.auths[auth_sid] = auth_ch
url, _ := auth.SinaOAuth2(auth_sid, func(data *auth.AuthUserData, accid uint64, err error) {
if data != nil && err == nil {
log.Trace("获得授权 auth_sid:%d data:%v", auth_sid, data)
auth_ch <- data
} else {
log.Trace(err.Error())
auth_ch <- nil
}
})
res.Accid = proto.Uint64(req.GetAccid())
res.AuthSid = proto.Uint64(auth_sid)
res.Url = proto.String(url)
return nil
}
开发者ID:playnb,项目名称:grasslands,代码行数:19,代码来源:superrpc.go
示例12: UserAuthorized
func UserAuthorized(state string, token *weixin.WebAccessToken, w http.ResponseWriter, r *http.Request) bool {
key := "NikeName:" + token.OpenID
ret, err := nosql.Redis.Get(key).Result()
if err != nil {
userinfo := weixin.GetUserInfo(token.OpenID, true)
if userinfo != nil {
ret, err = nosql.Redis.Set(key, userinfo.NikeName, 0).Result()
if err != nil {
log.Debug(err.Error() + " | " + ret)
} else {
log.Trace("App: %s 有人授权了(new)name: %s", state, userinfo.NikeName)
}
}
} else {
log.Trace("App: %s 有人授权了name: %s", state, ret)
}
return true
}
开发者ID:playnb,项目名称:grasslands,代码行数:18,代码来源:Main.go
示例13: InitAuthHttpService
func InitAuthHttpService() {
if default_http_service == nil {
default_http_service = new(AuthHttpService)
default_http_service.mux = http.NewServeMux()
default_http_service.mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Mustang authservice is running..."))
})
log.Trace("AuthService Listen On: " + AuthServicePort)
go http.ListenAndServe(":"+AuthServicePort, default_http_service.mux)
}
}
开发者ID:playnb,项目名称:mustang,代码行数:11,代码来源:http_serve.go
示例14: Save
func (token *WeiXinJsApiTicket) Save() {
var err error
if sqldb.Ormer.QueryTable(token).Filter("AppID", token.AppID).Exist() {
_, err = sqldb.Ormer.Update(token)
} else {
_, err = sqldb.Ormer.Insert(token)
}
if err != nil {
log.Error(err.Error())
} else {
log.Trace("保存微信AccessToken")
}
}
开发者ID:playnb,项目名称:mustang,代码行数:13,代码来源:models.go
示例15: main
func main() {
nosql.InitRedis(global.RedisURL, global.RedisPin, 0)
sqldb.Init()
mux := http.NewServeMux()
weixin.InitWeiXin(&weixin.WeiXinConfig{AppID: global.AppID,
AppSecret: global.AppSecret,
OwnerID: global.OwnerID,
ProcessMsg: nil,
UserAuthorized: UserAuthorized,
ServiceToken: "test_wx",
MyServiceDomain: global.ServiceDomain,
AuthRedirectURL: "http://" + global.ServiceDomain + "/wx/authorize_redirect"}, mux)
weixin.RegistAuthRedirectUrl("FIRST_TEST", "http://"+global.ServiceDomain+"/app/demo")
mux.HandleFunc("/htdoc/", handleStatic)
mux.HandleFunc("/app/demo", handleAppDemo)
mux.HandleFunc("/wx/api/", handleWxApi)
if err := http.ListenAndServe(":3000", mux); err != nil {
log.Error(err.Error())
}
//if err := http.ListenAndServeTLS(":3000", baseDir+"https/cert.pem", baseDir+"https/key.pem", mux); err != nil {
// log.Error(err.Error())
//}
return
log.Trace("启动......")
go superservice.Instance.StartService(utils.SuperRpcAddr)
go gateservice.Instance.StartService(utils.SuperRpcAddr)
<-utils.CloseSig
log.Trace("结束......")
return
test.TestSinaAuth()
auth.InitAuthHttpService()
test.TestProtorpc()
utils.TestSnow()
}
开发者ID:playnb,项目名称:grasslands,代码行数:39,代码来源:Main.go
示例16: Register
func (p *Processor) Register(msg proto.Message, msgHandler network.MsgHandler) {
msgType := reflect.TypeOf(msg)
msgName := msgType.String()[1:]
if msgType == nil || msgType.Kind() != reflect.Ptr {
log.Fatal("protobuf message pointer required")
}
if len(p.msgInfo) >= math.MaxUint16 {
log.Fatal("too many protobuf messages (max = %v)", math.MaxUint16)
}
i := new(MsgInfo)
i.msgType = msgType
i.msgName = msgName
i.msgHandler = msgHandler
p.msgInfo[msgName] = i
log.Trace("Register Msg Handle: %s", msgName)
}
开发者ID:playnb,项目名称:mustang,代码行数:17,代码来源:protobuf.go
示例17: TestProtorpc
func TestProtorpc() {
go startProtorpcService()
echoClient, err := Msg.DialEchoService("tcp", NetworkAddr)
for err != nil {
log.Error("连接服务失败 :%v", err)
time.Sleep(time.Second * 1)
echoClient, err = Msg.DialEchoService("tcp", NetworkAddr)
}
echoClient, err = Msg.DialEchoService("tcp", NetworkAddr)
wg := new(sync.WaitGroup)
for i := 0; i < 10; i++ {
wg.Add(1)
go func(i int) {
defer wg.Done()
log.Debug("RPC Call Begin..." + strconv.Itoa(i))
reply, err := echoClient.Echo(&Msg.EchoRequest{Msg: proto.String("Hello!" + strconv.Itoa(i))})
if err != nil {
log.Error("EchoTwice: %v", err)
}
log.Trace(reply.GetMsg())
log.Debug("RPC Call Finish..." + strconv.Itoa(i))
}(i)
}
/*
client, err := protorpc.Dial("tcp", `127.0.0.1:9527`)
if err != nil {
log.Fatal("protorpc.Dial: %v", err)
}
defer client.Close()
echoClient1 := &Msg.EchoServiceClient{client}
echoClient2 := &Msg.EchoServiceClient{client}
reply, err = echoClient1.Echo(args)
log.Trace(reply.GetMsg())
reply, err = echoClient2.EchoTwice(args)
log.Trace(reply.GetMsg())
_, _ = reply, err
*/
wg.Wait()
echoClient.Close()
}
开发者ID:playnb,项目名称:grasslands,代码行数:45,代码来源:test_protorpc.go
示例18: serverStub
func serverStub() {
transportFactory := thrift.NewTFramedTransportFactory(thrift.NewTTransportFactory())
protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
//protocolFactory := thrift.NewTCompactProtocolFactory()
serverTransport, err := thrift.NewTServerSocket(NetworkAddr)
if err != nil {
log.Error("Error!", err)
return
}
handler := &RpcServiceImpl{}
processor := demo.NewRpcServiceProcessor(handler)
server := thrift.NewTSimpleServer4(processor, serverTransport, transportFactory, protocolFactory)
log.Trace("thrift server in", NetworkAddr)
server.Serve()
}
开发者ID:playnb,项目名称:grasslands,代码行数:18,代码来源:test_thrift.go
示例19: ServeHTTP
//实现net.http.handler接口
//每次HTTP请求的时候被调用,用于产生链接
func (handler *WSHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer utils.PrintPanicStack()
log.Trace("new connect from %s(url:%s)", r.RemoteAddr, r.RequestURI)
if r.Method != "GET" {
http.Error(w, "Method not allowed", 405)
return
}
conn, err := handler.upgrader.Upgrade(w, r, nil)
if err != nil {
log.Debug("upgrade error: %v", err)
return
}
handler.wg.Add(1)
defer handler.wg.Done()
handler.mutexConns.Lock()
if handler.conns == nil {
handler.mutexConns.Unlock()
conn.Close()
log.Debug("upgrade error: nil")
return
}
if len(handler.conns) >= handler.maxConnNum {
handler.mutexConns.Unlock()
conn.Close()
log.Debug("too many connections")
return
}
handler.conns[conn] = struct{}{}
handler.mutexConns.Unlock()
wsConn := newWSConn(conn, handler.pendingWriteNum)
agent := handler.newAgent(wsConn)
agent.Run()
// cleanup
wsConn.Close()
handler.mutexConns.Lock()
delete(handler.conns, conn)
handler.mutexConns.Unlock()
agent.OnClose()
}
开发者ID:playnb,项目名称:mustang,代码行数:46,代码来源:websocket_server.go
示例20: Run
func (s *TcpServer) Run(closeSig chan bool) {
server := &network.TCPServer{}
server.Addr = s.Addr
server.MaxConnNum = 1000
server.PendingWriteNum = 1000
server.NewAgent = func(conn *network.TCPConn) network.IAgent {
a := new(TCPServerAgent)
a.server = s
a.SetConn(conn)
a.SetName("TCPServerAgent")
a.SetProtobufProcessor(protobuf.ProtobufProcess)
s.agent = a
return a
}
log.Trace("TCP服务器启动")
server.Start()
//等待close信号
<-closeSig
server.Close()
}
开发者ID:playnb,项目名称:grasslands,代码行数:20,代码来源:test_tcp.go
注:本文中的github.com/playnb/mustang/log.Trace函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论