當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Logger.Errorln函數代碼示例

本文整理匯總了Golang中Logger.Errorln函數的典型用法代碼示例。如果您正苦於以下問題:Golang Errorln函數的具體用法?Golang Errorln怎麽用?Golang Errorln使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Errorln函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: FindResource

// 獲得資源詳細信息
func FindResource(id string) (resourceMap map[string]interface{}, comments []map[string]interface{}) {
	condition := "id=" + id
	resource := model.NewResource()
	err := resource.Where(condition).Find()
	if err != nil {
		logger.Errorln("resource service FindResource error:", err)
		return
	}
	resourceMap = make(map[string]interface{})
	util.Struct2Map(resourceMap, resource)
	resourceMap["catname"] = GetCategoryName(resource.Catid)
	// 鏈接的host
	if resource.Form == model.LinkForm {
		urlObj, err := url.Parse(resource.Url)
		if err == nil {
			resourceMap["host"] = urlObj.Host
		}
	} else {
		resourceMap["url"] = "/resources/" + strconv.Itoa(resource.Id)
	}
	resourceEx := model.NewResourceEx()
	err = resourceEx.Where(condition).Find()
	if err != nil {
		logger.Errorln("resource service FindResource Error:", err)
		return
	}
	util.Struct2Map(resourceMap, resourceEx)
	// 評論信息
	comments, ownerUser, _ := FindObjComments(id, strconv.Itoa(model.TYPE_RESOURCE), resource.Uid, 0)
	resourceMap["user"] = ownerUser
	return
}
開發者ID:bluefchen,項目名稱:studygolang,代碼行數:33,代碼來源:resource.go

示例2: FindArticles

// 獲取抓取的文章列表(分頁)
func FindArticles(lastId, limit string) []*model.Article {
	article := model.NewArticle()

	cond := "status IN(0,1)"
	if lastId != "0" {
		cond += " AND id<" + lastId
	}

	articleList, err := article.Where(cond).Order("id DESC").Limit(limit).
		FindAll()
	if err != nil {
		logger.Errorln("article service FindArticles Error:", err)
		return nil
	}

	topArticles, err := article.Where("top=?", 1).Order("id DESC").FindAll()
	if err != nil {
		logger.Errorln("article service Find Top Articles Error:", err)
		return nil
	}
	if len(topArticles) > 0 {
		articleList = append(topArticles, articleList...)
	}

	return articleList
}
開發者ID:lewgun,項目名稱:studygolang,代碼行數:27,代碼來源:article.go

示例3: Tick

//entry call
func Tick(tradeAPI TradeAPI, records []Record) bool {

	strategyName := Option["strategy"]
	strategy, ok := strategys[strategyName]
	if !ok {
		logger.Errorf("sql: unknown strategy %q (forgotten import? private strategy?)", strategyName)
		return false
	}

	if strategyName != "OPENORDER" {
		length = len(records)
		//
		if length == 0 {
			logger.Errorln("warning:detect exception data", len(records))
			return false
		}

		//check exception data in trade center
		if checkException(records[length-2], records[length-1]) == false {
			logger.Errorln("detect exception data of trade center",
				records[length-2].Close, records[length-1].Close, records[length-1].Volumn)
			return false
		}

		lastPrice = records[length-1].Close
	}

	gTradeAPI = tradeAPI

	return strategy.Tick(records)
}
開發者ID:9cat,項目名稱:btcrobot,代碼行數:32,代碼來源:strategy.go

示例4: SaveRule

func SaveRule(form url.Values, opUser string) (errMsg string, err error) {
	rule := model.NewCrawlRule()
	err = util.ConvertAssign(rule, form)
	if err != nil {
		logger.Errorln("rule ConvertAssign error", err)
		errMsg = err.Error()
		return
	}

	rule.OpUser = opUser

	if rule.Id != 0 {
		err = rule.Persist(rule)
	} else {
		_, err = rule.Insert()
	}

	if err != nil {
		errMsg = "內部服務器錯誤"
		logger.Errorln("rule save:", errMsg, ":", err)
		return
	}

	return
}
開發者ID:lewgun,項目名稱:studygolang,代碼行數:25,代碼來源:article.go

示例5: FindTopicByTid

// 獲得帖子詳細信息(包括詳細回複)
// 為了避免轉換,tid傳string類型
func FindTopicByTid(tid string) (topicMap map[string]interface{}, replies []map[string]interface{}, err error) {
	condition := "tid=" + tid
	// 帖子信息
	topic := model.NewTopic()
	err = topic.Where(condition).Find()
	if err != nil {
		logger.Errorln("topic service FindTopicByTid Error:", err)
		return
	}
	// 帖子不存在
	if topic.Tid == 0 {
		return
	}
	topicMap = make(map[string]interface{})
	util.Struct2Map(topicMap, topic)
	topicEx := model.NewTopicEx()
	err = topicEx.Where(condition).Find()
	if err != nil {
		logger.Errorln("topic service FindTopicByTid Error:", err)
		return
	}
	if topicEx.Tid == 0 {
		return
	}
	util.Struct2Map(topicMap, topicEx)
	// 節點名字
	topicMap["node"] = model.GetNodeName(topic.Nid)

	// 回複信息(評論)
	replyList, err := model.NewComment().Where("objid=" + tid + " and objtype=" + strconv.Itoa(model.TYPE_TOPIC)).FindAll()
	if err != nil {
		logger.Errorln("topic service FindTopicByTid Error:", err)
		return
	}

	replyNum := len(replyList)
	uids := make(map[int]int, replyNum+1)
	uids[topic.Uid] = topic.Uid
	for _, reply := range replyList {
		uids[reply.Uid] = reply.Uid
	}

	// 獲得用戶信息
	userMap := getUserInfos(uids)
	topicMap["user"] = userMap[topic.Uid]

	// 有人回複
	if topic.Lastreplyuid != 0 {
		topicMap["lastreplyusername"] = userMap[topicMap["lastreplyuid"].(int)].Username
	}

	replies = make([]map[string]interface{}, 0, replyNum)
	for _, reply := range replyList {
		tmpMap := make(map[string]interface{})
		util.Struct2Map(tmpMap, reply)
		tmpMap["user"] = userMap[reply.Uid]
		replies = append(replies, tmpMap)
	}
	return
}
開發者ID:sndnvaps,項目名稱:studygolang,代碼行數:62,代碼來源:topic.go

示例6: SaveReading

// 保存晨讀
func SaveReading(form url.Values, username string) (errMsg string, err error) {
	reading := model.NewMorningReading()
	err = util.ConvertAssign(reading, form)
	if err != nil {
		logger.Errorln("reading SaveReading error", err)
		errMsg = err.Error()
		return
	}

	reading.Moreurls = strings.TrimSpace(reading.Moreurls)
	if strings.Contains(reading.Moreurls, "\n") {
		reading.Moreurls = strings.Join(strings.Split(reading.Moreurls, "\n"), ",")
	}

	reading.Username = username

	logger.Infoln(reading.Rtype, "id=", reading.Id)
	if reading.Id != 0 {
		err = reading.Persist(reading)
	} else {
		_, err = reading.Insert()
	}

	if err != nil {
		errMsg = "內部服務器錯誤"
		logger.Errorln("reading save:", errMsg, ":", err)
		return
	}

	return
}
開發者ID:bluefchen,項目名稱:studygolang,代碼行數:32,代碼來源:reading.go

示例7: SaveAuthority

func SaveAuthority(form url.Values, opUser string) (errMsg string, err error) {
	authority := model.NewAuthority()
	err = util.ConvertAssign(authority, form)
	if err != nil {
		logger.Errorln("authority ConvertAssign error", err)
		errMsg = err.Error()
		return
	}

	authority.OpUser = opUser

	if authority.Aid != 0 {
		err = authority.Persist(authority)
	} else {
		authority.Ctime = util.TimeNow()

		_, err = authority.Insert()
	}

	if err != nil {
		errMsg = "內部服務器錯誤"
		logger.Errorln(errMsg, ":", err)
		return
	}

	global.AuthorityChan <- struct{}{}

	return
}
開發者ID:bluefchen,項目名稱:studygolang,代碼行數:29,代碼來源:authority.go

示例8: LoadRoles

// 將所有 角色 加載到內存中;後台修改角色時,重新加載一次
func LoadRoles() error {
	roles, err := model.NewRole().FindAll()
	if err != nil {
		logger.Errorln("LoadRoles role read fail:", err)
		return err
	}

	if len(roles) == 0 {
		logger.Errorln("LoadRoles role read fail: num is 0")
		return errors.New("no role")
	}

	roleLocker.Lock()
	defer roleLocker.Unlock()

	maxRoleid := roles[len(roles)-1].Roleid
	Roles = make([]*model.Role, maxRoleid)

	// 由於角色不多,而且一般角色id是連續自增的,因此這裏以角色id當slice的index
	for _, role := range roles {
		Roles[role.Roleid-1] = role
	}

	logger.Infoln("LoadRoles successfully!")

	return nil
}
開發者ID:bluefchen,項目名稱:studygolang,代碼行數:28,代碼來源:data.go

示例9: FindUsers

func FindUsers() (map[int]*model.User, error) {
	userList, err := model.NewUser().FindAll()
	if err != nil {
		logger.Errorln("user service FindUsers Error:", err)
		return nil, err
	}
	userCount := len(userList)
	userMap := make(map[int]*model.User, userCount)
	uids := make([]int, userCount)
	for i, user := range userList {
		userMap[user.Uid] = user
		uids[i] = user.Uid
	}
	// 獲得角色信息
	userRoleList, err := model.NewUserRole().Where("uid in (" + util.Join(uids, ",") + ")").FindAll()
	if err != nil {
		logger.Errorln("user service FindUsers Error:", err)
		return nil, err
	}
	for _, userRole := range userRoleList {
		user := userMap[userRole.Uid]
		if len(user.Roleids) == 0 {
			user.Roleids = []int{userRole.Roleid}
			user.Rolenames = []string{model.AllRole[userRole.Roleid].Name}
		} else {
			user.Roleids = append(user.Roleids, userRole.Roleid)
			user.Rolenames = append(user.Rolenames, model.AllRole[userRole.Roleid].Name)
		}
	}
	return userMap, nil
}
開發者ID:jimmykuu,項目名稱:studygolang,代碼行數:31,代碼來源:user.go

示例10: FindAll

func (this *UserRole) FindAll(selectCol ...string) ([]*UserRole, error) {
	if len(selectCol) == 0 {
		selectCol = util.MapKeys(this.colFieldMap())
	}
	rows, err := this.Dao.FindAll(selectCol...)
	if err != nil {
		logger.Errorln("[UserRole.FindAll] error:", err)
		return nil, err
	}
	// TODO:
	userRoleList := make([]*UserRole, 0, 10)
	colNum := len(selectCol)
	for rows.Next() {
		userRole := NewUserRole()
		colFieldMap := userRole.colFieldMap()
		scanInterface := make([]interface{}, 0, colNum)
		for _, column := range selectCol {
			scanInterface = append(scanInterface, colFieldMap[column])
		}
		err = rows.Scan(scanInterface...)
		if err != nil {
			logger.Errorln("[UserRole.FindAll Rows] error:", err)
		}
		userRoleList = append(userRoleList, userRole)
	}
	return userRoleList, nil
}
開發者ID:jimmykuu,項目名稱:studygolang,代碼行數:27,代碼來源:user.go

示例11: PublishResource

// 增加資源
func PublishResource(uid int, form url.Values) bool {
	resource := model.NewResource()
	err := util.ConvertAssign(resource, form)
	if err != nil {
		logger.Errorln("user ConvertAssign error", err)
		return false
	}
	resource.Ctime = time.Now().Format("2006-01-02 15:04:05")
	resource.Uid = uid
	id, err := resource.Insert()
	if err != nil {
		logger.Errorln("PublishResource error:", err)
		return false
	}

	// 發布資源,活躍度+10
	go IncUserWeight("uid="+strconv.Itoa(uid), 10)

	// 入擴展表
	resourceEx := model.NewResourceEx()
	resourceEx.Id = int(id)
	if _, err := resourceEx.Insert(); err != nil {
		logger.Errorln("PublishResource Ex error:", err)
		return false
	}

	return true
}
開發者ID:Neeke,項目名稱:studygolang,代碼行數:29,代碼來源:resource.go

示例12: PostFilter

// 在邏輯處理完之後,最後展示頁麵
func (this *ViewFilter) PostFilter(rw http.ResponseWriter, req *http.Request) bool {
	contentHtml := req.FormValue(CONTENT_TPL_KEY)
	if contentHtml == "" {
		return true
	}
	// 為了使用自定義的模板函數,首先New一個以第一個模板文件名為模板名。
	// 這樣,在ParseFiles時,新返回的*Template便還是原來的模板實例
	tpl, err := template.New(this.baseTplName).Funcs(funcMap).ParseFiles(append(this.commonHtmlFiles, config.ROOT+contentHtml)...)
	if err != nil {
		logger.Errorln("解析模板出錯(ParseFiles):", err)
		return false
	}
	// 如果沒有定義css和js模板,則定義之
	if jsTpl := tpl.Lookup("js"); jsTpl == nil {
		tpl.Parse(`{{define "js"}}{{end}}`)
	}
	if jsTpl := tpl.Lookup("css"); jsTpl == nil {
		tpl.Parse(`{{define "css"}}{{end}}`)
	}

	data := GetData(req)
	// 當前用戶信息
	me, _ := CurrentUser(req)
	data["me"] = me
	err = tpl.Execute(rw, data)
	if err != nil {
		logger.Errorln("執行模板出錯(Execute):", err)
	}
	return true
}
開發者ID:jimmykuu,項目名稱:studygolang,代碼行數:31,代碼來源:view.go

示例13: Get_order

func (w *OkcoinTrade) Get_order(symbol, order_id string) (ret bool, m OKOrderTable) {
	pParams := make(map[string]string)
	pParams["partner"] = w.partner
	pParams["symbol"] = symbol
	pParams["order_id"] = order_id

	ret = true

	body, err := w.httpRequest(Config["ok_api_getorder"], 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.Errorln(err)
		logger.Errorln(body)
		logger.Errorln(m)
	}

	return
}
開發者ID:2yeslater,項目名稱:btcrobot,代碼行數:31,代碼來源:tradeapi.go

示例14: PostComment

// 發表評論。入topics_reply庫,更新topics和topics_ex庫
// objname 注冊的評論對象名
func PostComment(objid, objtype, uid int, content string, objname string) error {
	comment := model.NewComment()
	comment.Objid = objid
	comment.Objtype = objtype
	comment.Uid = uid
	comment.Content = content

	// TODO:評論樓層怎麽處理,避免衝突?最後的樓層信息保存在內存中?

	// 暫時隻是從數據庫中取出最後的評論樓層
	stringBuilder := util.NewBuffer()
	stringBuilder.Append("objid=").AppendInt(objid).Append(" AND objtype=").AppendInt(objtype)
	tmpCmt, err := model.NewComment().Where(stringBuilder.String()).Order("ctime DESC").Find()
	if err != nil {
		logger.Errorln("post comment service error:", err)
		return err
	} else {
		comment.Floor = tmpCmt.Floor + 1
	}
	// 入評論庫
	cid, err := comment.Insert()
	if err != nil {
		logger.Errorln("post comment service error:", err)
		return err
	}
	// 回調,不關心處理結果(有些對象可能不需要回調)
	if commenter, ok := commenters[objname]; ok {
		logger.Debugf("評論[objid:%d] [objtype:%d] [uid:%d] 成功,通知被評論者更新", objid, objtype, uid)
		go commenter.UpdateComment(cid, objid, uid, time.Now().Format("2006-01-02 15:04:05"))
	}

	return nil
}
開發者ID:jimmykuu,項目名稱:studygolang,代碼行數:35,代碼來源:comment.go

示例15: 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
}
開發者ID:kalllx,項目名稱:btcrobot,代碼行數:59,代碼來源:huobiapi.go


注:本文中的Logger.Errorln函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。