Commit 93c11fc8 authored by zauberstuhl's avatar zauberstuhl

Changed api logger to new MultiLogger

Old one is deprecated see https://revel.github.io/manual/logging.html
parent 4077c6c8
......@@ -36,13 +36,13 @@ func (a ApiAspect) ShowPerson() revel.Result {
user, err := models.GetCurrentUser(a.Session["TOKEN"])
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error("Failed to get current user :%s", err.Error())
return a.RenderError(err)
}
err = aspects.FindByUserPersonID(user.ID, personID)
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error("Failed to find user by person id :%s", err.Error())
return a.RenderError(err)
}
......@@ -62,7 +62,7 @@ func (a ApiAspect) CreatePerson() revel.Result {
err := membership.Create()
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error("Failed to create membership :%s", err.Error())
return a.RenderError(err)
}
......@@ -82,7 +82,7 @@ func (a ApiAspect) DeletePerson() revel.Result {
err := membership.Delete()
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error("Failed to delete membership :%s", err.Error())
return a.RenderError(err)
}
......@@ -92,7 +92,7 @@ func (a ApiAspect) DeletePerson() revel.Result {
func (a ApiAspect) Index() revel.Result {
user, err := models.GetCurrentUser(a.Session["TOKEN"])
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error("Failed to get current user :%s", err.Error())
return a.RenderError(err)
}
......@@ -104,22 +104,22 @@ func (a ApiAspect) Create() revel.Result {
personID, err := strconv.ParseUint(
a.Params.Get("personID"), 0, 64)
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error("Failed parsing uint :%s", err.Error())
return a.RenderError(err)
}
revel.TRACE.Println("params", name, personID)
revel.AppLog.Debug("params", name, personID)
user, err := models.GetCurrentUser(a.Session["TOKEN"])
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error("Failed to get current user :%s", err.Error())
return a.RenderError(err)
}
var person models.Person
err = person.FindByID(uint(personID))
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error("Failed finding person by id :%s", err.Error())
return a.RenderError(err)
}
......@@ -133,11 +133,11 @@ func (a ApiAspect) Create() revel.Result {
},
}
revel.TRACE.Println("aspect", aspect)
revel.AppLog.Debug("aspect", aspect)
err = aspect.Create()
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error("Failed creating an aspect :%s", err.Error())
return a.RenderError(err)
}
......
......@@ -37,7 +37,7 @@ func (c ApiComment) Index() revel.Result {
c.Params.Bind(&postID, "id")
err := comments.FindByPostID(postID)
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return c.NotFound("Post not found")
}
return c.RenderJSON(comments)
......@@ -55,13 +55,13 @@ func (c ApiComment) Create() revel.Result {
user, err := models.GetCurrentUser(c.Session["TOKEN"])
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return c.RenderError(err)
}
err = post.FindByID(postID, true)
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return c.NotFound("Post not found")
}
......
......@@ -38,7 +38,7 @@ func (l ApiLike) Index() revel.Result {
l.Params.Bind(&postID, "id")
err := likes.FindByPostID(postID)
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return l.NotFound("Post not found")
}
......@@ -58,19 +58,19 @@ func (l ApiLike) Create() revel.Result {
err := post.FindByID(postID, true)
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return l.NotFound("Post not found")
}
user, err := models.GetCurrentUser(l.Session["TOKEN"])
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return l.RenderError(err)
}
guid, err := helpers.Uuid()
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return l.RenderError(err)
}
......@@ -84,7 +84,7 @@ func (l ApiLike) Create() revel.Result {
err = like.Create(&entityLike)
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return l.RenderError(err)
}
......@@ -100,7 +100,7 @@ func (l ApiLike) Create() revel.Result {
var parentUser models.User
err = parentUser.FindByID(user.Person.UserID)
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return l.RenderError(err)
}
dispatcher.ParentUser = &parentUser
......
......@@ -43,7 +43,7 @@ func (p ApiPeople) Show() revel.Result {
p.Params.Bind(&personID, "id")
err := person.FindByID(personID)
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return p.NotFound("Person not found")
}
......
......@@ -42,13 +42,13 @@ func (p ApiPost) Index() revel.Result {
user, err := models.GetCurrentUser(p.Session["TOKEN"])
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return p.RenderError(err)
}
err = posts.FindAll(user.ID, offset)
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return p.RenderError(err)
}
......@@ -68,20 +68,20 @@ func (p ApiPost) Create() revel.Result {
emptyPost, err := regexp.MatchString(`^\s*?$`, postText)
if err == nil && emptyPost {
err = errors.New("Cannot submit an empty post!")
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return p.RenderError(err)
}
user, err := models.GetCurrentUser(p.Session["TOKEN"])
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return p.RenderError(err)
}
// create post
guid, err := helpers.Uuid()
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return p.RenderError(err)
}
......@@ -101,7 +101,7 @@ func (p ApiPost) Create() revel.Result {
// save post locally
err = post.Create(&entity, false)
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return p.RenderError(err)
}
......@@ -113,7 +113,7 @@ func (p ApiPost) Create() revel.Result {
UserID: user.ID,
ShareableType: models.ShareablePost,
}; if err := shareable.Create(); err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return p.RenderError(err)
}
......@@ -125,7 +125,7 @@ func (p ApiPost) Create() revel.Result {
ShareableType: models.ShareablePost,
}
if err := visibility.Create(); err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return p.RenderError(err)
}
}
......@@ -149,7 +149,7 @@ func (p ApiPost) Show() revel.Result {
p.Params.Bind(&postID, "id")
err := post.FindByID(postID, false)
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return p.NotFound("Post not found")
}
......
......@@ -39,7 +39,7 @@ func (p ApiProfile) Show() revel.Result {
p.Params.Bind(&personID, "id")
err := profile.FindByPersonID(personID)
if err != nil {
revel.ERROR.Println(err)
revel.AppLog.Error(err.Error())
return p.NotFound("Profile not found")
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment