TLDR:
- If you want to log an object, put the object as the first argument, and the message string as the second argument!
- If you want to log an error, it must be the first argument, and not deep inside an object.
- (I don't know how to log an error and also an object for context, but it might be possible)
Working patterns:
fastify.log.info("message")
fastify.log.info(error, "message")
fastify.log.info({ data }, "message")Patterns which don't work:
// Only logs: { error: "[object Error]" }
fastify.log.info({ error }, "message")
// Only logs the message!
fastify.log.info("message", { data })