I'm starting to use external packages for my lambda function which is written in Golang.
I use serverless framework if that makes any difference.
I want to centralize the error logging every time there's an error in the DB.
but I notice that the log doesn't show on the cloudwatch. Only the logs in the main
package shows.
here's my code
package response
func ServerError(err error) (events.APIGatewayProxyResponse, error) {
log.Print(fmt.Errorf("ERROR: %v", err))
return Custom(500, "Internal Server Error", nil)
}
I also tried
package response
func ServerError(err error) (events.APIGatewayProxyResponse, error) {
fmt.Println(fmt.Errorf("ERROR: %v", err))
return Custom(500, "Internal Server Error", nil)
}
My question is how can I enable logging in lambda outside of main package?
Thanks!
EDIT
It turns out that log.Print(fmt.Errorf("ERROR: %v", err))
works as well. I must've missed it the last time.