本文整理汇总了Golang中Logger.Infoln函数的典型用法代码示例。如果您正苦于以下问题:Golang Infoln函数的具体用法?Golang Infoln怎么用?Golang Infoln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Infoln函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: PreFilter
// PreFilter 执行 handler 之前的过滤方法
func (this *SensitiveFilter) PreFilter(rw http.ResponseWriter, req *http.Request) bool {
logger.Debugln("SensitiveFilter PreFilter...")
content := req.FormValue("content")
title := req.FormValue("title")
if title == "" && content == "" {
return true
}
curUser, _ := CurrentUser(req)
// 标题特殊处理
for _, s := range titleSensitives {
if util.HasSensitiveChar(title, s) {
// 把账号冻结
service.UpdateUserStatus(curUser["uid"].(int), model.StatusFreeze)
logger.Infoln("user=", curUser["uid"], "publish ad, title=", title, ";content=", content, ". freeze")
return false
}
}
sensitive := config.Config["sensitive"]
if util.HasSensitive(title, sensitive) || util.HasSensitive(content, sensitive) {
// 把账号冻结
service.UpdateUserStatus(curUser["uid"].(int), model.StatusFreeze)
logger.Infoln("user=", curUser["uid"], "publish ad, title=", title, ";content=", content, ". freeze")
return false
}
return true
}
示例2: Get_order
func (w *PeatioTrade) Get_order(id string) (ret bool, m HBOrder) {
pParams := make(map[string]string)
pParams["method"] = "order_info"
pParams["access_key"] = w.access_key
pParams["id"] = id
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
logger.Infoln(err)
return
}
_, ret = w.check_json_result(body)
if ret == false {
logger.Infoln(body)
return
}
doc := json.NewDecoder(strings.NewReader(body))
if err := doc.Decode(&m); err == io.EOF {
ret = false
logger.Infoln(err)
} else if err != nil {
ret = false
logger.Infoln(err)
}
return
}
示例3: Sell
func Sell() string {
if PrevTrade == "sell" {
return "0"
}
// compute the price
price, _, warning := getSellPrice()
// compute the amount
Available_coin := GetAvailable_coin()
if Available_coin < 0.01 {
warning = "没有足够的币"
logger.Infoln(warning)
PrevTrade = "sell"
PrevBuyPirce = 0
return "0"
}
amount := Option["tradeAmount"]
nAmount, err := strconv.ParseFloat(amount, 64)
if err != nil {
logger.Infoln("amount is not float")
return "0"
}
if nAmount > Available_coin {
nAmount = Available_coin
amount = fmt.Sprintf("%02f", nAmount)
}
sellID := sell(price, amount)
if sellID == "-1" {
warning += " [模拟]"
} else if sellID == "0" {
warning += "[委托失败]"
} else {
warning += "[委托成功]" + sellID
}
logger.Infoln(warning)
var coin string
if Option["symbol"] == "btc_cny" {
coin = "比特币"
} else {
coin = "莱特币"
}
if sellID != "0" {
if !GetBacktest() {
logger.Tradef("在%s,根据策略%s周期%s,以价格%s卖出%s个%s\n", Option["tradecenter"], Option["strategy"], Option["tick_interval"], price, amount, coin)
go email.TriggerTrender(warning)
} else {
t := time.Unix(GetBtTime(), 0)
logger.Backtestf("%s 在simulate,根据策略%s周期%s,以价格%s卖出%s个%s\n", t.Format("2006-01-02 15:04:05"), Option["strategy"], Option["tick_interval"], price, amount, coin)
}
}
return sellID
}
示例4: Buy
func (w Okcoin) Buy(tradePrice, tradeAmount string) bool {
tradeAPI := NewOkcoinTrade(SecretOption["ok_partner"], SecretOption["ok_secret_key"])
var buyId string
symbol := Option["symbol"]
if symbol == "btc_cny" {
buyId = tradeAPI.BuyBTC(tradePrice, tradeAmount)
} else if symbol == "ltc_cny" {
buyId = tradeAPI.BuyLTC(tradePrice, tradeAmount)
}
if buyId != "0" {
logger.Infoln("执行买入委托成功", tradePrice, tradeAmount)
} else {
logger.Infoln("执行买入委托失败", tradePrice, tradeAmount)
}
time.Sleep(3 * time.Second)
_, ret := w.Get_account_info()
if !ret {
logger.Infoln("Get_account_info failed")
}
if buyId != "0" {
return true
} else {
return false
}
}
示例5: Get_order
func (w *BitvcTrade) Get_order(id string) (ret bool, m HBOrder) {
pParams := make(map[string]string)
ret = true
body, err := w.httpRequest(pParams)
if err != nil {
ret = false
logger.Infoln(err)
return
}
_, ret = w.check_json_result(body)
if ret == false {
logger.Infoln(body)
return
}
doc := json.NewDecoder(strings.NewReader(body))
if err := doc.Decode(&m); err == io.EOF {
ret = false
logger.Infoln(err)
} else if err != nil {
ret = false
logger.Infoln(err)
}
return
}
示例6: Buy
func Buy() string {
if PrevTrade == "buy" {
return "0"
}
//init
isStoploss = false
//compute the price
price, nPrice, warning := getBuyPrice()
//compute the amount
amount := Option["tradeAmount"]
nAmount, err := strconv.ParseFloat(amount, 64)
if err != nil {
logger.Infoln("amount is not float")
return "0"
}
Available_cny := GetAvailable_cny()
if Available_cny < nPrice*nAmount {
var nMinTradeAmount float64
nAmount = Available_cny / nPrice
symbol := Option["symbol"]
if symbol == "btc_cny" {
nMinTradeAmount = 0.1
} else {
nMinTradeAmount = 0.01
}
if nAmount < nMinTradeAmount {
warning += "没有足够的法币余额"
logger.Infoln(warning)
PrevTrade = "buy"
PrevBuyPirce = nPrice
return "0"
}
amount = fmt.Sprintf("%02f", nAmount)
}
warning += "---->数量" + amount
buyID := buy(price, amount)
if buyID == "-1" {
warning += " [模拟]"
} else if buyID == "0" {
warning += "[委托失败]"
} else {
warning += "[委托成功]" + buyID
}
logger.Infoln(warning)
go email.TriggerTrender(warning)
return buyID
}
示例7: indexing
func indexing(isAll bool) {
logger.Infoln("indexing start...")
start := time.Now()
defer func() {
logger.Infoln("indexing spend time:", time.Now().Sub(start))
}()
service.Indexing(isAll)
}
示例8: trade
func (w *Huobi) trade(emaShort, emaLong []float64, EMAMinThreshold float64,
TresholdLevel int, length int, tradeOnlyAfterSwitch int, tradeAmount string) {
currentTrend := getTrendAtIndex(emaShort, emaLong, EMAMinThreshold, TresholdLevel, length-1)
logger.Debugln("currentTrend is ", currentTrend)
if currentTrend > 1 {
// Trend is up
if currentTrend == 3 {
// Trend is up, also according to the "Buy after X samples"-setting
if (tradeOnlyAfterSwitch == 1) && (w.latestSolidTrend == 3) {
// tradeOnlyAfterSwitch==true but the trend has not switched: Don't trade
logger.Debugln("Trend has not switched (still up). The setting \"tradeOnlyAfterSwitch==true\", so do not trade...")
return
}
w.latestSolidTrend = 3
if Option["disable_trading"] == "1" {
logger.Debugln("Simulted BUY (Simulation only: no trade was made)")
} else {
logger.Infoln("Trend has switched, 探测到买入点")
go service.TriggerTrender("探测到买入点")
w.Do_buy(w.getTradePrice("buy"), tradeAmount)
}
//logger.Infoln("Trend is up, but no " + currency + " to spend...");
} else {
logger.Debugf("Trend is up, but not for long enough (needs to be \"up\" for at least %d samples)\n", TresholdLevel)
}
} else if currentTrend < -1 {
// Trend is down
if currentTrend == -3 {
// Trend is down, also according to the "Sell after X samples"-setting
if (tradeOnlyAfterSwitch == 1) && (w.latestSolidTrend == -3) {
// tradeOnlyAfterSwitch==true but the trend has not switched: Don't trade
logger.Debugln("Trend has not switched (still down). The setting \"tradeOnlyAfterSwitch==true\", so do not trade...")
return
}
w.latestSolidTrend = -3
if Option["disable_trading"] == "1" {
logger.Infoln("Simulted SELL (Simulation only: no trade was made)")
} else {
logger.Infoln("Trend has switched, 探测到卖出点")
go service.TriggerTrender("探测到卖出点")
w.Do_sell(w.getTradePrice("sell"), tradeAmount)
}
//logger.Infoln("Trend is down, but no BTC to sell...");
} else {
logger.Debugf("Trend is down, but not for long enough (needs to be \"down\" for at least t %d samples)\n", TresholdLevel)
}
} else {
logger.Debugln("Trend is undefined/weak")
}
}
示例9: supervisor
func supervisor(mess chan message) {
for i := 0; i < worker_number; i++ {
m := <-mess
switch m.normal {
case true:
logger.Infoln("exit normal, nothing serious!")
case false:
logger.Infoln("exit abnormal, something went wrong")
}
}
}
示例10: sell
func sell(price, amount string) string {
Available_coin := GetAvailable_coin()
if Available_coin < 0.01 {
warning = "没有足够的币"
logger.Infoln(warning)
PrevTrade = "sell"
PrevBuyPirce = 0
return "0"
}
nAmount, err := strconv.ParseFloat(amount, 64)
if err != nil {
logger.Infoln("amount is not float")
return "0"
}
if nAmount > Available_coin {
nAmount = Available_coin
amount = fmt.Sprintf("%02f", nAmount)
}
var sellID string
if Option["enable_trading"] == "1" {
sellID = gTradeAPI.Sell(price, amount)
} else {
sellID = "-1"
}
if sellID != "0" {
timestamp := time.Now()
magic += 1
if !GetBacktest() {
err := db.SetTx("sell", sellID, timestamp.Unix(), price, amount, magic)
if err != nil {
fmt.Println("SetTx", err)
}
}
sellOrders[timestamp] = sellID
PrevTrade = "sell"
PrevBuyPirce = 0
}
if !GetBacktest() {
cmd, id, timestamp, amount, price, magic, err := db.GetTx(sellID)
if err != nil {
fmt.Println("GetTx", err)
} else {
fmt.Println("sell items:", cmd, id, timestamp, amount, price, magic)
}
}
return sellID
}
示例11: GetOrders
func (w Huobi) GetOrders() (ret bool, orders []HBOrder) {
tradeAPI := NewHuobiTrade(SecretOption["huobi_access_key"], SecretOption["huobi_secret_key"])
ret, orders = tradeAPI.Get_orders()
if ret {
logger.Infoln("Get orders ok", len(orders))
} else {
logger.Infoln("Get orders failed")
}
return
}
示例12: doTradeDelegation
func doTradeDelegation() {
huobi := huobiapi.NewHuobi()
logger.Infoln("doTradeDelegation start....")
if huobi.Login() == true {
logger.Debugln("Login successfully.")
huobi.TradeDelegation()
} else {
logger.Debugln("Login failed.")
}
logger.Infoln("doTradeDelegation end-----")
}
示例13: Do_sell
func (w *BitvcTrade) Do_sell(tradePrice, tradeAmount string) bool {
if w.Login() == true {
if w.TradeAdd("do_sell", tradePrice, tradeAmount) == true {
logger.Infoln("执行卖出委托成功", tradePrice, tradeAmount)
return true
} else {
logger.Infoln("执行卖出失败,原因:卖出操作被服务器拒绝", tradePrice, tradeAmount)
}
} else {
logger.Infoln("执行卖出失败,原因:登陆失败", tradePrice, tradeAmount)
}
return false
}
示例14: doTradeDelegation
func doTradeDelegation() {
huobi := huobiapi.NewHuobi()
logger.Infoln("doTradeDelegation start....")
if huobi.Login() == true {
console.SetColor(console.FOREGROUND_GREEN)
logger.Debugln("Login successfully.")
huobi.TradeDelegation()
} else {
logger.Debugln("Login failed.")
}
logger.Infoln("doTradeDelegation end-----")
}
示例15: OrderBook
func (w *Huobi) OrderBook(body string) bool {
body = strings.TrimPrefix(body, "view_detail(")
body = strings.TrimSuffix(body, ")")
ioutil.WriteFile("cache/OrderBook.json", []byte(body), 0644)
var orderBook OrderBook
if err := json.Unmarshal([]byte(body), &orderBook); err != nil {
logger.Infoln(err)
return false
}
logger.Infoln(orderBook)
return true
}