本文整理汇总了Golang中Logger.Debugln函数的典型用法代码示例。如果您正苦于以下问题:Golang Debugln函数的具体用法?Golang Debugln怎么用?Golang Debugln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Debugln函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Tick
//circular strategy
func (circular *circularStrategy) Tick(records []Record) bool {
if circular.PrevClosePrice == lastPrice {
return false
}
basePrice, err := strconv.ParseFloat(Option["basePrice"], 64)
if err != nil {
logger.Debugln("config item basePrice is not float")
return false
}
fluctuation, err := strconv.ParseFloat(Option["fluctuation"], 64)
if err != nil {
logger.Debugln("config item fluctuation is not float")
return false
}
circular.PrevClosePrice = lastPrice
logger.Infof("lastPrice %0.02f\n", lastPrice)
if lastPrice >= basePrice+fluctuation {
Sell()
} else if lastPrice <= basePrice-fluctuation {
Buy()
}
//do sell when price is below stoploss point
processStoploss(lastPrice)
processTimeout()
return true
}
示例2: TriggerPrice
func TriggerPrice(price float64) error {
lowest_price, err := strconv.ParseFloat(Option["lowest_price"], 64)
if err != nil {
logger.Debugln("config item lowest_price is not float")
return err
}
highest_price, err := strconv.ParseFloat(Option["highest_price"], 64)
if err != nil {
logger.Debugln("config item highest_price is not float")
return err
}
var alert string
if Option["disable_email"] != "1" {
if price < lowest_price {
alert = fmt.Sprintf("价格 %f 低于设定的阀值 %f", price, Option["lowest_price"])
} else if price > highest_price {
alert = fmt.Sprintf("价格 %f 超过设定的阀值 %f", price, Option["highest_price"])
}
if alert != "" {
SendAlertEmail(Option["to_email"], alert)
}
}
return nil
}
示例3: decrUserActiveWeight
func decrUserActiveWeight() {
logger.Debugln("start decr user active weight...")
loginTime := time.Now().Add(-72 * time.Hour)
userList, err := service.FindNotLoginUsers(loginTime.Format(util.TIME_LAYOUT_OFTEN))
if err != nil {
logger.Errorln("获取最近未登录用户失败:", err)
return
}
logger.Debugln("need dealing users:", len(userList))
for _, user := range userList {
divide := 5
lastLoginTime, err := util.TimeParseOften(user.LoginTime)
if err == nil {
hours := (loginTime.Sub(lastLoginTime) / 24).Hours()
if hours < 24 {
divide = 2
} else if hours < 48 {
divide = 3
} else if hours < 72 {
divide = 4
}
}
logger.Debugln("decr user weight, username:", user.Username, "divide:", divide)
service.DecrUserWeight("username='"+user.Username+"'", divide)
}
logger.Debugln("end decr user active weight...")
}
示例4: parse_topsell
// just fuck the huobi old shit bug
func parse_topsell(topsells map[string]interface{}, topsells_data *[5]Top_buy_sell) bool {
index := 4
for k, v := range topsells {
switch vt := v.(type) {
case map[string]interface{}:
logger.Debugln(k, " is a map:")
logger.Debugf("topsells[%s]\n", k)
for ik, iv := range vt {
logger.Debugln(ik, iv)
switch ik {
case "price":
topsells_data[index].Price = util.InterfaceToFloat64(iv)
case "amount":
topsells_data[index].Amount = util.InterfaceToFloat64(iv)
case "level":
topsells_data[index].Level = util.InterfaceToFloat64(iv)
case "accu":
topsells_data[index].Accu = util.InterfaceToFloat64(iv)
}
}
index--
default:
logger.Errorln(k, v)
logger.Fatalln("don't know the type, crash!")
return false
}
}
return true
}
示例5: ReadCSV
func ReadCSV(path string) (data [][]string) {
file, err := os.Open(path)
if err != nil {
logger.Debugln("Error:", err)
return
}
defer file.Close()
reader := csv.NewReader(file)
data, err2 := reader.ReadAll()
if err2 != nil {
logger.Debugln("Error:", err2)
return
}
return data
//flag := 0
//for {
// record, err := reader.Read()
// if err == io.EOF {
// break
// } else if err != nil {
// logger.Debugln("Error:", err)
// return
// }
// data[flag] = record
// flag++
// //fmt.Println(record) // record has the type []string
//}
}
示例6: TradeDelegationAnalyze
func (w *Huobi) TradeDelegationAnalyze(body string) bool {
logger.Debugln("TradeDelegationAnalyze start....")
var ids []string
for _, pat := range strings.Split(body, `">撤单`) {
if len(pat) == 0 {
// Empty strings such as from a trailing comma can be ignored.
continue
}
patLev := strings.Split(pat, "a=cancel&id=")
if len(patLev) != 2 || len(patLev[0]) == 0 || len(patLev[1]) == 0 {
logger.Debugln("parse end")
break
}
logger.Debugln(patLev[1])
ids = append(ids, patLev[1])
}
logger.Debugln(ids)
w.TradeCancel1stPage(ids)
logger.Debugln("TradeDelegationAnalyze end-----")
return true
}
示例7: checkAccount
func (w *Huobi) checkAccount(a, price, amount string) bool {
btc, cny := w.get_account_info()
FPrice, err := strconv.ParseFloat(price, 64)
if err != nil {
logger.Debugln("price is not float")
return false
}
FAmount, err := strconv.ParseFloat(amount, 64)
if err != nil {
logger.Debugln("amount is not float")
return false
}
if a == "do_buy" {
if float64(cny) < FPrice*FAmount {
return false
}
} else {
if float64(btc) < FAmount {
return false
}
}
return true
}
示例8: EngineHandler
func EngineHandler(rw http.ResponseWriter, req *http.Request) {
vars := mux.Vars(req)
msgtype := vars["msgtype"]
if req.Method != "POST" && msgtype == "" {
// 获取用户信息
err := config.LoadOption()
if err != nil {
logger.Errorln(err)
fmt.Fprint(rw, `{"errno": 1, "msg":"`, "读取引擎配置数据失败", `"}`)
return
}
// 设置模板数据
filter.SetData(req, map[string]interface{}{"config": config.Option})
req.Form.Set(filter.CONTENT_TPL_KEY, "/template/trade/engine.html")
return
} else if req.Method != "POST" && msgtype == "ajax" {
Option_json, err := json.Marshal(config.Option)
if err != nil {
logger.Errorln(err)
fmt.Fprint(rw, `{"errno": 1, "msg":"`, "读取引擎配置数据失败", `"}`)
} else {
fmt.Fprint(rw, string(Option_json))
}
return
} else {
logger.Debugln("===[", req.FormValue("disable_trading"), "]")
if req.FormValue("disable_trading") == "on" {
config.Option["disable_trading"] = "1"
} else {
config.Option["disable_trading"] = "0"
}
logger.Debugln("===[", req.FormValue("disable_backtesting"), "]")
if req.FormValue("disable_backtesting") == "on" {
config.Option["disable_backtesting"] = "1"
} else {
config.Option["disable_backtesting"] = "0"
}
config.Option["tick_interval"] = req.FormValue("tick_interval")
config.Option["shortEMA"] = req.FormValue("shortEMA")
config.Option["longEMA"] = req.FormValue("longEMA")
config.Option["tradeAmount"] = req.FormValue("tradeAmount")
config.Option["totalHour"] = req.FormValue("totalHour")
// 更新个人信息
err := config.SaveOption()
if err != nil {
fmt.Fprint(rw, `{"errno": 1, "msg":"`, "写入引擎配置数据失败", `"}`)
return
}
fmt.Fprint(rw, `{"errno": 0, "msg":"更新引擎配置成功!"}`)
}
}
示例9: TradeCancel1stPage
func (w *Huobi) TradeCancel1stPage(ids []string) bool {
logger.Debugln("TradeCancel1stPage start....")
for _, id := range ids {
w.TradeCancel(id)
}
logger.Debugln("TradeCancel1stPage end-----")
return true
}
示例10: PreFilter
func (this *LoginFilter) PreFilter(rw http.ResponseWriter, req *http.Request) bool {
logger.Debugln("LoginFilter PreFilter...")
if _, ok := CurrentUser(req); !ok {
logger.Debugln("需要登录")
// 没有登录
util.Redirect(rw, req, "/account/login")
return false
}
return true
}
示例11: 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")
}
}
示例12: PreFilter
func (this *LoginFilter) PreFilter(rw http.ResponseWriter, req *http.Request) bool {
logger.Debugln("LoginFilter PreFilter...")
if _, ok := CurrentUser(req); !ok {
logger.Debugln("需要登录")
// 支持跳转回原来访问的页面
NewFlash(rw, req).AddFlash(req.RequestURI, "uri")
util.Redirect(rw, req, "/account/login")
return false
}
return true
}
示例13: SendAlertEmail
func SendAlertEmail(receiver, alert string) error {
// Set up authentication information.
auth := smtp.PlainAuth("", SecretOption["smtp_username"], SecretOption["smtp_password"], SecretOption["smtp_host"])
from := mail.Address{"BTCRobot监控中心", SecretOption["smtp_username"]}
to := mail.Address{"收件人", receiver}
title := "BTCRobot来电--->" + alert
body := `
<html>
<body>
<h3>
%s
</h3>
<p>
捐助BTC,支持开发<span style="font-size: 80%"><a href="bitcoin:1NDnnWCUu926z4wxA3sNBGYWNQD3mKyes8">1NDnnWCUu926z4wxA3sNBGYWNQD3mKyes8</a></span>
</p>
</body>
</html>
`
body = fmt.Sprintf(body, alert)
header := make(map[string]string)
header["From"] = from.String()
header["To"] = to.String()
header["Subject"] = encodeRFC2047(title)
header["MIME-Version"] = "1.0"
header["Content-Type"] = "text/html; charset=\"utf-8\""
header["Content-Transfer-Encoding"] = "base64"
message := ""
for k, v := range header {
message += fmt.Sprintf("%s: %s\r\n", k, v)
}
message += "\r\n" + base64.StdEncoding.EncodeToString([]byte(body))
logger.Debugln("Try sending Mail to", to)
// Connect to the server, authenticate, set the sender and recipient,
// and send the email all in one step.
err := smtp.SendMail(
SecretOption["smtp_addr"],
auth,
from.Address,
[]string{to.Address},
[]byte(message))
if err != nil {
logger.Infoln("Send Mail to", to, "error:", err)
return err
}
logger.Debugln("Send Mail to", to, "Successfully")
return nil
}
示例14: 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-----")
}
示例15: FindAll
// FindAll 查找多条数据
func (this *Dao) FindAll(selectCol ...string) (*sql.Rows, error) {
sort.Sort(sort.StringSlice(selectCol))
this.selectCols = "`" + strings.Join(selectCol, "`,`") + "`"
strSql := util.SelectSql(this)
logger.Debugln("FindAll sql:", strSql)
logger.Debugln("FindAll bind params:", this.whereVal)
err := this.Open()
if err != nil {
return nil, err
}
defer this.Close()
return this.Query(strSql, this.whereVal...)
}