本文整理汇总了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)
}
}