Sunday, 5 January 2025

Show HN: LogLayer – Unified logger that routes logs to various logging libraries https://bit.ly/421mozO

Show HN: LogLayer – Unified logger that routes logs to various logging libraries As a longtime TypeScript/Node.js developer, I've often faced challenges with logging—choosing, using, and maintaining the right logger for various projects. While most loggers offer the usual methods like "info", "warn", and "error", they vary significantly in how they handle structured metadata or Error objects. This can lead to ad-hoc solutions, like serializing errors or writing custom pipelines, just to get logs formatted correctly. I built LogLayer to address these pain points by introducing a fluid, expressive API. With methods like "withMetadata" and "withError", LogLayer separates object injection from the log message itself, making your logging code both cleaner and more maintainable. Logs are processed through a LogLayer Transport, which acts as an adapter for your preferred logging library. This design offers several key advantages: - Multi-Transport Support: Send logs to multiple destinations (e.g., DataDog and New Relic) simultaneously. I've personally used this feature to ship logs directly to DataDog without relying on their APM package or sidecars. - Easy Logger Swapping: If you’ve ever used Pino with Next.js, you might have encountered issues where it doesn’t work out of the box after a production build without webpack hacks. With LogLayer, you can swap in a better-suited library without touching your logging code. I spent a good few months on and off and used my winter break to launch version 5 of LogLayer, and also created the documentation using Vitepress. LogLayer has been battle-tested in production at Airtop ( https://bit.ly/3BN9I4W ), where it’s been an integral part of our systems for years (we were running as Switchboard for almost four years and pivoted late last year). (Disclaimer: I work at Airtop, but LogLayer is not sponsored / affiliated with them.) https://bit.ly/421HLAV January 6, 2025 at 01:52AM

No comments:

Post a Comment