本文整理汇总了Golang中github.com/polaris1119/logger.Errorln函数的典型用法代码示例。如果您正苦于以下问题:Golang Errorln函数的具体用法?Golang Errorln怎么用?Golang Errorln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Errorln函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:studygolang,项目名称:studygolang,代码行数:29,代码来源:data.go
示例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
}
开发者ID:studygolang,项目名称:studygolang,代码行数:32,代码来源:reading.go
示例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
}
开发者ID:studygolang,项目名称:studygolang,代码行数:33,代码来源:reddit.go
示例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()
}
}
}
开发者ID:studygolang,项目名称:studygolang,代码行数:52,代码来源:searcher.go
示例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
}
开发者ID:studygolang,项目名称:studygolang,代码行数:14,代码来源:sitemap.go
示例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()
}
}
}
开发者ID:studygolang,项目名称:studygolang,代码行数:51,代码来源:searcher.go
示例7: Total
// 会员总数
func (UserLogic) Total() int64 {
total, err := MasterDB.Count(new(model.User))
if err != nil {
logger.Errorln("UserLogic Total error:", err)
}
return total
}
开发者ID:studygolang,项目名称:studygolang,代码行数:8,代码来源:user.go
示例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)
}
}
开发者ID:studygolang,项目名称:studygolang,代码行数:9,代码来源:topic.go
示例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)
}
}
开发者ID:studygolang,项目名称:studygolang,代码行数:18,代码来源:topic.go
示例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
}
开发者ID:studygolang,项目名称:studygolang,代码行数:8,代码来源:article.go
示例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)
}
}
开发者ID:studygolang,项目名称:studygolang,代码行数:9,代码来源:project.go
示例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)
}
}
开发者ID:studygolang,项目名称:studygolang,代码行数:7,代码来源:message.go
示例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
}
开发者ID:studygolang,项目名称:studygolang,代码行数:8,代码来源:project.go
示例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
}
开发者ID:studygolang,项目名称:studygolang,代码行数:29,代码来源:uploader.go
示例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)
}
}
开发者ID:studygolang,项目名称:studygolang,代码行数:9,代码来源:article.go
示例16: Total
// Total 资源总数
func (ResourceLogic) Total() int64 {
total, err := MasterDB.Count(new(model.Resource))
if err != nil {
logger.Errorln("CommentLogic Total error:", err)
}
return total
}
开发者ID:studygolang,项目名称:studygolang,代码行数:8,代码来源:resource.go
示例17: UpdateComment
// UpdateComment 更新该文章的评论信息
// cid:评论id;objid:被评论对象id;uid:评论者;cmttime:评论时间
func (self ArticleComment) UpdateComment(cid, objid, uid int, cmttime time.Time) {
// 更新评论数(TODO:暂时每次都更新表)
_, err := MasterDB.Id(objid).Incr("cmtnum", 1).Update(new(model.Article))
if err != nil {
logger.Errorln("更新文章评论数失败:", err)
}
}
开发者ID:studygolang,项目名称:studygolang,代码行数:9,代码来源:article.go
示例18: decrUserActiveWeight
func decrUserActiveWeight() {
logger.Debugln("start decr user active weight...")
loginTime := time.Now().Add(-72 * time.Hour)
userList, err := logic.DefaultUser.FindNotLoginUsers(loginTime)
if err != nil {
logger.Errorln("获取最近未登录用户失败:", err)
return
}
logger.Debugln("need dealing users:", len(userList))
for _, user := range userList {
divide := 5
if err == nil {
hours := (loginTime.Sub(user.LoginTime) / 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)
logic.DefaultUser.DecrUserWeight("username", user.Username, divide)
}
logger.Debugln("end decr user active weight...")
}
开发者ID:studygolang,项目名称:studygolang,代码行数:32,代码来源:background.go
示例19: LoadRoleAuthorities
// 将所有 角色拥有的权限 加载到内存中;后台修改时,重新加载一次
func LoadRoleAuthorities() error {
roleAuthorities := make([]*model.RoleAuthority, 0)
err := MasterDB.Find(&roleAuthorities)
if err != nil {
logger.Errorln("LoadRoleAuthorities role_authority read fail:", err)
return err
}
roleAuthLocker.Lock()
defer roleAuthLocker.Unlock()
RoleAuthorities = make(map[int][]int)
for _, roleAuth := range roleAuthorities {
roleId := roleAuth.Roleid
if authorities, ok := RoleAuthorities[roleId]; ok {
RoleAuthorities[roleId] = append(authorities, roleAuth.Aid)
} else {
RoleAuthorities[roleId] = []int{roleAuth.Aid}
}
}
logger.Infoln("LoadRoleAuthorities successfully!")
return nil
}
开发者ID:studygolang,项目名称:studygolang,代码行数:28,代码来源:data.go
示例20: ReadList
// ReadList 获得wiki列表
func (WikiController) ReadList(ctx echo.Context) error {
limit := 20
lastId := goutils.MustInt(ctx.QueryParam("lastid"))
wikis := logic.DefaultWiki.FindBy(ctx, limit+5, lastId)
if wikis == nil {
logger.Errorln("wiki controller: find wikis error")
return ctx.Redirect(http.StatusSeeOther, "/wiki")
}
num := len(wikis)
if num == 0 {
if lastId == 0 {
return ctx.Redirect(http.StatusSeeOther, "/")
}
return ctx.Redirect(http.StatusSeeOther, "/wiki")
}
var (
hasPrev, hasNext bool
prevId, nextId int
)
if lastId != 0 {
prevId = lastId
// 避免因为wiki下线,导致判断错误(所以 > 5)
if prevId-wikis[0].Id > 5 {
hasPrev = false
} else {
prevId += limit
hasPrev = true
}
}
if num > limit {
hasNext = true
wikis = wikis[:limit]
nextId = wikis[limit-1].Id
} else {
nextId = wikis[num-1].Id
}
pageInfo := map[string]interface{}{
"has_prev": hasPrev,
"prev_id": prevId,
"has_next": hasNext,
"next_id": nextId,
}
// 获取当前用户喜欢对象信息
// me, ok := ctx.Get("user").(*model.Me)
// var likeFlags map[int]int
// if ok {
// likeFlags, _ = logic.DefaultLike.FindUserLikeObjects(ctx, me.Uid, model.TypeWiki, wikis[0].Id, nextId)
// }
return render(ctx, "wiki/list.html", map[string]interface{}{"wikis": wikis, "activeWiki": "active", "page": pageInfo})
}
开发者ID:studygolang,项目名称:studygolang,代码行数:60,代码来源:wiki.go
注:本文中的github.com/polaris1119/logger.Errorln函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论