Fixing Pino's Logging Limitations For (Message, Payload)
Pino logging library for Node.js doesn't natively support logging a message alongside an object like console.log. A custom solution is proposed to fix this behavior while preserving Pino's structure and performance.
Introduction Pino is a blazing-fast logging library for Node.js, built for structured logs and high performance. However, one common frustration developers face is that Pino does not natively support logging a message alongside an object the way console.log does. Note: this is my approach and a solution that works well for me. If you have any suggestions, improvements, or use a different method in your projects, I’d love to hear your thoughts! The Problem If you log with: logger.info('User created', { userId: 123 }); You expect: INFO [12:30:45] User cre...