Open ORESoftware opened 4 years ago
The only solution that I know of is to do something like this:
func logAndEcho(...args interface{}) string {
log.Info(args)
return args;
}
func (ctr *TagsController) DeleteTags(c *common.Context, user *common.User, org *common.Organization, req *http.Request, params martini.Params) (int, interface{}) {
tagName, hasTag := params["tag"]
if !hasTag {
return 422, ctr.ErrorResponse(422, logAndEcho(errors.New("missing tag: no tag param to update")))
}
}
using the above, we can log it and send it back in the same line
I have this:
is there a way to read the response, given the status code? If we send an error back to the client, how can I intercept the error message and log it?
for example, if we use:
I would want to log XXX from the final martini middleware, since the status code is greater than 399. How to do this?
Furthermore, it would be nice to send in private/public logging - the client message and the error message. Using Node.js express we could do this:
is there a way to send the client a different message, but still hook into the error object so we can log it easily instead of having to log it manually everywhere?