本文整理汇总了Golang中Logger.Traceln函数的典型用法代码示例。如果您正苦于以下问题:Golang Traceln函数的具体用法?Golang Traceln怎么用?Golang Traceln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Traceln函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetAccount
func (w Okcoin) GetAccount() (account Account, ret bool) {
tradeAPI := NewOkcoinTrade(SecretOption["ok_partner"], SecretOption["ok_secret_key"])
userInfo, ret := tradeAPI.GetAccount()
logger.Infoln("account:", userInfo)
if !ret {
logger.Traceln("okcoin GetAccount failed")
return
} else {
logger.Traceln(userInfo)
account.Available_cny = userInfo.Info.Funds.Free.CNY
account.Available_btc = userInfo.Info.Funds.Free.BTC
account.Available_ltc = userInfo.Info.Funds.Free.LTC
account.Frozen_cny = userInfo.Info.Funds.Freezed.CNY
account.Frozen_btc = userInfo.Info.Funds.Freezed.BTC
account.Frozen_ltc = userInfo.Info.Funds.Freezed.LTC
logger.Infof("okcoin资产: \n 可用cny:%-10s \tbtc:%-10s \tltc:%-10s \n 冻结cny:%-10s \tbtc:%-10s \tltc:%-10s\n",
account.Available_cny,
account.Available_btc,
account.Available_ltc,
account.Frozen_cny,
account.Frozen_btc,
account.Frozen_ltc)
//logger.Infoln(Account)
return
}
}
示例2: Cancel_order
func (w *BitvcTrade) Cancel_order(id string) bool {
pParams := make(map[string]string)
body, err := w.httpRequest(pParams)
if err != nil {
return false
}
_, ret := w.check_json_result(body)
if ret == false {
return false
}
doc := json.NewDecoder(strings.NewReader(body))
type Msg struct {
Result string
}
var m Msg
if err := doc.Decode(&m); err == io.EOF {
logger.Traceln(err)
} else if err != nil {
logger.Fatal(err)
}
logger.Traceln(m)
if m.Result == "success" {
return true
} else {
return false
}
}
示例3: Get_orders
func (w *HuobiTrade) Get_orders() (m []Order, ret bool) {
pParams := make(map[string]string)
pParams["method"] = "get_orders"
pParams["access_key"] = w.access_key
now := time.Now().Unix()
pParams["created"] = strconv.FormatInt(now, 10)
pParams["sign"] = w.createSign(pParams)
ret = true
body, err := w.httpRequest(pParams)
if err != nil {
ret = false
return
}
_, ret = w.check_json_result(body)
if ret == false {
return
}
doc := json.NewDecoder(strings.NewReader(body))
if err := doc.Decode(&m); err == io.EOF {
logger.Traceln(err)
} else if err != nil {
logger.Fatal(err)
}
logger.Traceln(m)
return
}
示例4: Get_account_info
func (w *OkcoinTrade) Get_account_info() (userInfo UserInfo, ret bool) {
api_url := "https://www.okcoin.com/api/userinfo.do"
pParams := make(map[string]string)
pParams["partner"] = w.partner
ret = true
body, err := w.httpRequest(api_url, pParams)
if err != nil {
ret = false
return
}
_, ret = w.check_json_result(body)
if ret == false {
return
}
logger.Traceln(body)
doc := json.NewDecoder(strings.NewReader(body))
if err := doc.Decode(&userInfo); err == io.EOF {
ret = false
logger.Traceln(err)
} else if err != nil {
ret = false
logger.Fatal(err)
}
logger.Traceln(userInfo)
return
}
示例5: parse_topsell
func parse_topsell(topsells map[string]interface{}, topsells_data *[5]Top_buy_sell) {
index := 4
for k, v := range topsells {
switch vt := v.(type) {
case map[string]interface{}:
logger.Traceln(k, " is a map:")
logger.Tracef("topsells[%s]\n", k)
for ik, iv := range vt {
logger.Traceln(ik, iv)
switch ik {
case "price":
topsells_data[index].Price = InterfaceToFloat64(iv)
case "amount":
topsells_data[index].amount = InterfaceToFloat64(iv)
case "level":
topsells_data[index].level = InterfaceToFloat64(iv)
case "accu":
topsells_data[index].accu = InterfaceToFloat64(iv)
}
}
index--
default:
logger.Errorln(k, v)
logger.Fatalln("don't know the type, crash!")
}
}
}
示例6: Get_order
func (w *OkcoinTrade) Get_order(symbol, order_id string) (m OrderTable, ret bool) {
api_url := "https://www.okcoin.com/api/getorder.do"
pParams := make(map[string]string)
pParams["partner"] = w.partner
pParams["symbol"] = symbol
pParams["order_id"] = order_id
ret = true
body, err := w.httpRequest(api_url, pParams)
if err != nil {
ret = false
return
}
_, ret = w.check_json_result(body)
if ret == false {
return
}
doc := json.NewDecoder(strings.NewReader(body))
if err := doc.Decode(&m); err == io.EOF {
logger.Traceln(err)
} else if err != nil {
logger.Fatal(err)
}
logger.Traceln(m)
return
}
示例7: getOrderBook
func (w *Huobi) getOrderBook(symbol string) (ret bool, hbOrderBook OrderBook) {
// init to false
ret = false
var huobisymbol string
if symbol == "btc_cny" {
huobisymbol = "huobibtccny"
} else {
huobisymbol = "huobiltccny"
logger.Fatal("huobi does not support LTC by now, wait for huobi provide it.", huobisymbol)
return
}
rnd := util.RandomString(20)
now := time.Now().UnixNano() / 1000000
req, err := http.NewRequest("GET", fmt.Sprintf(Config["hb_trade_detail"], rnd, now, now), nil)
if err != nil {
logger.Fatal(err)
return
}
req.Header.Set("Referer", Config["base_url"])
req.Header.Add("Connection", "keep-alive")
req.Header.Add("User-Agent", "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36")
req.Header.Add("Accept-Encoding", "identity")
resp, err := http.DefaultClient.Do(req)
if err != nil {
logger.Traceln(err)
logger.Traceln(req)
logger.Traceln(resp)
return
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
logger.Errorf("HTTP returned status %v", resp)
return
}
var body string
contentEncoding := resp.Header.Get("Content-Encoding")
logger.Tracef("HTTP returned Content-Encoding %s", contentEncoding)
switch contentEncoding {
case "gzip":
body = util.DumpGZIP(resp.Body)
default:
bodyByte, err := ioutil.ReadAll(resp.Body)
if err != nil {
logger.Errorln("read the http stream failed")
return
} else {
body = string(bodyByte)
ioutil.WriteFile("cache/OrderBook.json", bodyByte, 0644)
}
}
return w.analyzeOrderBook(body)
}
示例8: Get_orders
func (w *BitvcTrade) Get_orders() (ret bool, m []HBOrderItem) {
pParams := make(map[string]string)
ret = true
body, err := w.httpRequest(pParams)
if err != nil {
ret = false
return
}
_, ret = w.check_json_result(body)
if ret == false {
return
}
doc := json.NewDecoder(strings.NewReader(body))
if err := doc.Decode(&m); err == io.EOF {
logger.Traceln(err)
} else if err != nil {
logger.Fatal(err)
}
logger.Traceln(m)
return
}
示例9: Get_account_info
func (w Okcoin) Get_account_info() (userMoney common.UserMoney, ret bool) {
tradeAPI := NewOkcoinTrade(SecretOption["ok_partner"], SecretOption["ok_secret_key"])
userInfo, ret := tradeAPI.Get_account_info()
if !ret {
logger.Traceln("okcoin Get_account_info failed")
return
} else {
logger.Traceln(userInfo)
userMoney.Available_cny = userInfo.Info.Funds.Free.CNY
userMoney.Available_btc = userInfo.Info.Funds.Free.BTC
userMoney.Available_ltc = userInfo.Info.Funds.Free.LTC
userMoney.Frozen_cny = userInfo.Info.Funds.Freezed.CNY
userMoney.Frozen_btc = userInfo.Info.Funds.Freezed.BTC
userMoney.Frozen_ltc = userInfo.Info.Funds.Freezed.LTC
logger.Infof("okcoin资产: \n 可用cny:%-10s \tbtc:%-10s \tltc:%-10s \n 冻结cny:%-10s \tbtc:%-10s \tltc:%-10s\n",
userMoney.Available_cny,
userMoney.Available_btc,
userMoney.Available_ltc,
userMoney.Frozen_cny,
userMoney.Frozen_btc,
userMoney.Frozen_ltc)
//logger.Infoln(userMoney)
return
}
}
示例10: GetAccount
func (w Okcoin) GetAccount() (account Account, ret bool) {
tradeAPI := w.tradeAPI
userInfo, ret := tradeAPI.GetAccount()
if !ret {
logger.Traceln("okcoin GetAccount failed")
return
} else {
logger.Traceln(userInfo)
account.Available_cny = userInfo.Info.Funds.Free.CNY
account.Available_btc = userInfo.Info.Funds.Free.BTC
account.Available_ltc = userInfo.Info.Funds.Free.LTC
account.Frozen_cny = userInfo.Info.Funds.Freezed.CNY
account.Frozen_btc = userInfo.Info.Funds.Freezed.BTC
account.Frozen_ltc = userInfo.Info.Funds.Freezed.LTC
logger.Infof("okcoin资产: \n 可用cny:%-10s \tbtc:%-10s \tltc:%-10s \n 冻结cny:%-10s \tbtc:%-10s \tltc:%-10s\n",
account.Available_cny,
account.Available_btc,
account.Available_ltc,
account.Frozen_cny,
account.Frozen_btc,
account.Frozen_ltc)
return
}
}
示例11: GetAccount
func (w *OkcoinTrade) GetAccount() (userInfo UserInfo, ret bool) {
pParams := make(map[string]string)
pParams["partner"] = w.partner
ret = true
body, err := w.httpRequest(Config["ok_api_userinfo"], pParams)
if err != nil {
ret = false
return
}
_, ret = w.check_json_result(body)
if ret == false {
return
}
logger.Traceln(body)
doc := json.NewDecoder(strings.NewReader(body))
if err := doc.Decode(&userInfo); err == io.EOF {
ret = false
logger.Traceln(err)
} else if err != nil {
ret = false
logger.Fatal(err)
}
logger.Traceln(userInfo)
return
}
示例12: TradeKLinePeroid
func (w *Huobi) TradeKLinePeroid(peroid int) (ret bool) {
req, err := http.NewRequest("GET", fmt.Sprintf(Config["trade_kline_url"], peroid, rand.Float64()), nil)
if err != nil {
logger.Fatal(err)
return false
}
req.Header.Set("Referer", Config["trade_flash_url"])
req.Header.Add("Connection", "keep-alive")
req.Header.Add("User-Agent", "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36")
logger.Traceln(req)
if w.client == nil {
w.client = &http.Client{nil, nil, nil}
}
resp, err := w.client.Do(req)
if err != nil {
logger.Errorln(err)
return false
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
var body string
contentEncoding := resp.Header.Get("Content-Encoding")
logger.Tracef("HTTP returned Content-Encoding %s", contentEncoding)
switch contentEncoding {
case "gzip":
body = DumpGZIP(resp.Body)
default:
bodyByte, err := ioutil.ReadAll(resp.Body)
if err != nil {
logger.Errorln("read the http stream failed")
return false
} else {
body = string(bodyByte)
ioutil.WriteFile(fmt.Sprintf("cache/TradeKLine_%03d.data", peroid), bodyByte, os.ModeAppend)
}
}
logger.Traceln(resp.Header.Get("Content-Type"))
ret := strings.Contains(body, "您需要登录才能继续")
if ret {
logger.Traceln("您需要登录才能继续")
return false
} else {
return w.AnalyzePeroidLine(fmt.Sprintf("cache/TradeKLine_%03d.data", peroid), body)
}
} else {
logger.Tracef("HTTP returned status %v", resp)
}
return false
}
示例13: AnalyzeKLinePeroid
func (w *Huobi) AnalyzeKLinePeroid(symbol string, peroid int) (ret bool, records []Record) {
ret = false
var huobisymbol string
if symbol == "btc_cny" {
huobisymbol = "huobibtccny"
} else {
huobisymbol = "huobiltccny"
logger.Fatal("huobi does not support LTC by now, wait for huobi provide it.", huobisymbol)
return
}
req, err := http.NewRequest("GET", fmt.Sprintf(Config["hb_kline_url"], peroid), nil)
if err != nil {
logger.Fatal(err)
return
}
req.Header.Set("Referer", Config["hb_base_url"])
req.Header.Add("Connection", "keep-alive")
req.Header.Add("User-Agent", "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36")
logger.Traceln(req)
c := util.NewTimeoutClient()
logger.Tracef("HTTP req begin AnalyzeKLinePeroid")
resp, err := c.Do(req)
logger.Tracef("HTTP req end AnalyzeKLinePeroid")
if err != nil {
logger.Traceln(err)
return
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
logger.Tracef("HTTP returned status %v", resp)
return
}
var body string
contentEncoding := resp.Header.Get("Content-Encoding")
logger.Tracef("HTTP returned Content-Encoding %s", contentEncoding)
logger.Traceln(resp.Header.Get("Content-Type"))
switch contentEncoding {
case "gzip":
body = util.DumpGZIP(resp.Body)
default:
bodyByte, err := ioutil.ReadAll(resp.Body)
if err != nil {
logger.Errorln("read the http stream failed")
return
} else {
body = string(bodyByte)
}
}
ioutil.WriteFile(fmt.Sprintf("cache/hbKLine_%03d.data", peroid), []byte(body), 0644)
return analyzePeroidLine(fmt.Sprintf("cache/hbKLine_%03d.data", peroid))
}
示例14: httpRequest
func (w *HuobiTrade) httpRequest(pParams map[string]string) (string, error) {
v := url.Values{}
for key, val := range pParams {
v.Add(key, val)
}
req, err := http.NewRequest("POST", Config["api_url"], strings.NewReader(v.Encode()))
if err != nil {
logger.Fatal(err)
return "", err
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Referer", "https://www.huobi.com/")
req.Header.Add("Connection", "keep-alive")
req.Header.Add("User-Agent", "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36")
logger.Traceln(req)
c := util.NewTimeoutClient()
logger.Tracef("HTTP req begin HuobiTrade")
resp, err := c.Do(req)
logger.Tracef("HTTP req end HuobiTrade")
if err != nil {
logger.Fatal(err)
return "", err
}
defer resp.Body.Close()
logger.Tracef("api_url resp StatusCode=%v", resp.StatusCode)
logger.Tracef("api_url resp=%v", resp)
if resp.StatusCode == 200 {
var body string
contentEncoding := resp.Header.Get("Content-Encoding")
logger.Tracef("HTTP returned Content-Encoding %s", contentEncoding)
logger.Traceln(resp.Header.Get("Content-Type"))
switch contentEncoding {
case "gzip":
body = DumpGZIP(resp.Body)
default:
bodyByte, _ := ioutil.ReadAll(resp.Body)
body = string(bodyByte)
ioutil.WriteFile("cache/api_url.json", bodyByte, 0644)
}
logger.Traceln(body)
return body, nil
} else {
logger.Tracef("resp %v", resp)
}
return "", nil
}
示例15: getOrderBook
func (w *Okcoin) getOrderBook(symbol string) (ret bool, orderBook OrderBook) {
//init to false
ret = false
req, err := http.NewRequest("GET", fmt.Sprintf(Config["ok_depth_url"], symbol), nil)
if err != nil {
logger.Fatal(err)
return
}
req.Header.Set("Referer", Config["ok_base_url"])
req.Header.Add("Connection", "keep-alive")
req.Header.Add("User-Agent", "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36")
logger.Traceln(req)
c := util.NewTimeoutClient()
logger.Tracef("HTTP req begin getOrderBook")
resp, err := c.Do(req)
logger.Tracef("HTTP req end getOrderBook")
if err != nil {
logger.Traceln(err)
return
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
logger.Errorf("HTTP returned status %v", resp)
return
}
var body string
contentEncoding := resp.Header.Get("Content-Encoding")
logger.Tracef("HTTP returned Content-Encoding %s", contentEncoding)
switch contentEncoding {
case "gzip":
body = util.DumpGZIP(resp.Body)
default:
bodyByte, err := ioutil.ReadAll(resp.Body)
if err != nil {
logger.Errorln("read the http stream failed")
return
} else {
body = string(bodyByte)
ioutil.WriteFile("cache/okdepth.json", bodyByte, 0644)
}
}
return w.analyzeOrderBook(body)
}