本文整理匯總了Golang中github.com/polaris1119/logger.Errorln函數的典型用法代碼示例。如果您正苦於以下問題:Golang Errorln函數的具體用法?Golang Errorln怎麽用?Golang Errorln使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Errorln函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: LoadRoles
// 將所有 角色 加載到內存中;後台修改角色時,重新加載一次
func LoadRoles() error {
roles := make([]*model.Role, 0)
err := MasterDB.Find(&roles)
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
}
示例2: SaveReading
// SaveReading 保存晨讀
func (ReadingLogic) SaveReading(ctx context.Context, form url.Values, username string) (errMsg string, err error) {
reading := &model.MorningReading{}
err = schemaDecoder.Decode(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.Debugln(reading.Rtype, "id=", reading.Id)
if reading.Id != 0 {
_, err = MasterDB.Update(reading)
} else {
_, err = MasterDB.Insert(reading)
}
if err != nil {
errMsg = "內部服務器錯誤"
logger.Errorln("reading save:", errMsg, ":", err)
return
}
return
}
示例3: Parse
// Parse 獲取url對應的資源並根據規則進行解析
func (this *RedditLogic) Parse(redditUrl string) error {
redditUrl = strings.TrimSpace(redditUrl)
if redditUrl == "" {
redditUrl = this.domain + this.golang
} else if !strings.HasPrefix(redditUrl, "https") {
redditUrl = "https://" + redditUrl
}
var (
doc *goquery.Document
err error
)
// if doc, err = goquery.NewDocument(redditUrl); err != nil {
if doc, err = this.newDocumentFromResp(redditUrl); err != nil {
logger.Errorln("goquery reddit newdocument error:", err)
return err
}
// 最後麵的先入庫處理
resourcesSelection := doc.Find("#siteTable .link")
for i := resourcesSelection.Length() - 1; i >= 0; i-- {
err = this.dealRedditOneResource(goquery.NewDocumentFromNode(resourcesSelection.Get(i)).Selection)
if err != nil {
logger.Errorln(err)
}
}
return err
}
示例4: IndexingTopic
// 索引主題
func (self SearcherLogic) IndexingTopic(isAll bool) {
solrClient := NewSolrClient()
var (
topicList []*model.Topic
topicExList map[int]*model.TopicEx
err error
)
if isAll {
id := 0
for {
topicList = make([]*model.Topic, 0)
topicExList = make(map[int]*model.TopicEx)
err = MasterDB.Where("tid>?", id).OrderBy("tid ASC").Limit(self.maxRows).Find(&topicList)
if err != nil {
logger.Errorln("IndexingTopic error:", err)
break
}
if len(topicList) == 0 {
break
}
tids := util.Models2Intslice(topicList, "Tid")
err = MasterDB.In("tid", tids).Find(&topicExList)
if err != nil {
logger.Errorln("IndexingTopic error:", err)
break
}
for _, topic := range topicList {
if id < topic.Tid {
id = topic.Tid
}
topicEx := topicExList[topic.Tid]
document := model.NewDocument(topic, topicEx)
addCommand := model.NewDefaultArgsAddCommand(document)
solrClient.PushAdd(addCommand)
}
solrClient.Post()
}
}
}
示例5: output
func output(filename string, data map[string]interface{}) (err error) {
var file *os.File
file, err = os.Create(sitemapPath + filename)
if err != nil {
logger.Errorln("open file error:", err)
return
}
defer file.Close()
if err = sitemapTpl.Execute(file, data); err != nil {
logger.Errorln("execute template error:", err)
}
return
}
示例6: IndexingResource
// 索引資源
func (self SearcherLogic) IndexingResource(isAll bool) {
solrClient := NewSolrClient()
var (
resourceList []*model.Resource
resourceExList map[int]*model.ResourceEx
err error
)
if isAll {
id := 0
for {
resourceList = make([]*model.Resource, 0)
resourceExList = make(map[int]*model.ResourceEx)
err = MasterDB.Where("id>?", id).OrderBy("id ASC").Limit(self.maxRows).Find(&resourceList)
if err != nil {
logger.Errorln("IndexingResource error:", err)
break
}
if len(resourceList) == 0 {
break
}
ids := util.Models2Intslice(resourceList, "Id")
err = MasterDB.In("id", ids).Find(&resourceExList)
if err != nil {
logger.Errorln("IndexingResource error:", err)
break
}
for _, resource := range resourceList {
if id < resource.Id {
id = resource.Id
}
resourceEx := resourceExList[resource.Id]
document := model.NewDocument(resource, resourceEx)
addCommand := model.NewDefaultArgsAddCommand(document)
solrClient.PushAdd(addCommand)
}
solrClient.Post()
}
}
}
示例7: Total
// 會員總數
func (UserLogic) Total() int64 {
total, err := MasterDB.Count(new(model.User))
if err != nil {
logger.Errorln("UserLogic Total error:", err)
}
return total
}
示例8: UpdateLike
// 更新該主題的喜歡數
// objid:被喜歡對象id;num: 喜歡數(負數表示取消喜歡)
func (self TopicLike) UpdateLike(objid, num int) {
// 更新喜歡數(TODO:暫時每次都更新表)
_, err := MasterDB.Where("tid=?", objid).Incr("like", num).Update(new(model.TopicEx))
if err != nil {
logger.Errorln("更新主題喜歡數失敗:", err)
}
}
示例9: UpdateComment
// UpdateComment 更新該主題的回複信息
// cid:評論id;objid:被評論對象id;uid:評論者;cmttime:評論時間
func (self TopicComment) UpdateComment(cid, objid, uid int, cmttime time.Time) {
// 更新最後回複信息
_, err := MasterDB.Table(new(model.Topic)).Id(objid).Update(map[string]interface{}{
"lastreplyuid": uid,
"lastreplytime": cmttime,
})
if err != nil {
logger.Errorln("更新主題最後回複人信息失敗:", err)
}
// 更新回複數(TODO:暫時每次都更新表)
_, err = MasterDB.Id(objid).Incr("reply", 1).Update(new(model.TopicEx))
if err != nil {
logger.Errorln("更新主題回複數失敗:", err)
}
}
示例10: Total
// Total 博文總數
func (ArticleLogic) Total() int64 {
total, err := MasterDB.Count(new(model.Article))
if err != nil {
logger.Errorln("ArticleLogic Total error:", err)
}
return total
}
示例11: UpdateLike
// 更新該項目的喜歡數
// objid:被喜歡對象id;num: 喜歡數(負數表示取消喜歡)
func (self ProjectLike) UpdateLike(objid, num int) {
// 更新喜歡數(TODO:暫時每次都更新表)
_, err := MasterDB.Id(objid).Incr("likenum", num).Update(new(model.OpenProject))
if err != nil {
logger.Errorln("更新項目喜歡數失敗:", err)
}
}
示例12: SetExt
func (this *SystemMessage) SetExt(ext map[string]interface{}) {
if extBytes, err := json.Marshal(ext); err != nil {
logger.Errorln("SystemMessage SetExt JsonMarshal Error:", err)
} else {
this.Ext = string(extBytes)
}
}
示例13: Total
// Total 開源項目總數
func (ProjectLogic) Total() int64 {
total, err := MasterDB.Count(new(model.OpenProject))
if err != nil {
logger.Errorln("ProjectLogic Total error:", err)
}
return total
}
示例14: uploadLocalFile
func (this *UploaderLogic) uploadLocalFile(localFile, key string) (err error) {
this.genUpToken()
var ret io.PutRet
var extra = &io.PutExtra{
// Params: params,
// MimeType: mieType,
// Crc32: crc32,
// CheckCrc: CheckCrc,
}
// ret 變量用於存取返回的信息,詳情見 io.PutRet
// uptoken 為業務服務器生成的上傳口令
// key 為文件存儲的標識(文件名)
// localFile 為本地文件名
// extra 為上傳文件的額外信息,詳情見 io.PutExtra,可選
err = io.PutFile(nil, &ret, this.uptoken, key, localFile, extra)
if err != nil {
//上傳產生錯誤
logger.Errorln("io.PutFile failed:", err)
return
}
//上傳成功,處理返回值
logger.Debugln(ret.Hash, ret.Key)
return
}
示例15: UpdateLike
// 更新該文章的喜歡數
// objid:被喜歡對象id;num: 喜歡數(負數表示取消喜歡)
func (self ArticleLike) UpdateLike(objid, num int) {
// 更新喜歡數(TODO:暫時每次都更新表)
_, err := MasterDB.Where("id=?", objid).Incr("likenum", num).Update(new(model.Article))
if err != nil {
logger.Errorln("更新文章喜歡數失敗:", err)
}
}