Table of Contents:
package main
import (
"github.com/djmarrerajr/common-lib/errs"
"github.com/djmarrerajr/common-lib/utils"
)
func main() {
logger := utils.NewLogger("INFO")
err := validate()
if err != nil {
logger.Error("startup failed", err)
}
}
func validate() error {
return errs.New(errs.ErrTypeValidation, "validation failed")
}
... and the output:
$ go run main.go 2>&1 | jq
{
"level": "error",
"ts": 1683114890.155433,
"caller": "main.go:13",
"msg": "startup failed",
"error.message": "validation failed",
"stacktrace": "main.main\n\t/main.go:13\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:250"
}