How to add module or file names for log lines in winston?

--

Every application I have shipped in past 15 years had logging enabled in one way or another. The 12 Factor App also mentions importance of logging. In node.js applications I have been using Winston as a logging package. Unlike Java or PHP logging package managers, getting module name or file name in logs was not straightforward. Here is how I do it:

For obvious reasons, do not just copy paste. I am using a JSON format, you may not need it. Add 🧂 per your taste and enjoy!

--

--

Kumar Chetan Sharma
Kumar Chetan Sharma

Written by Kumar Chetan Sharma

Full Stack developer & architect from 🇮🇳. 😨 of CS, Algos & DS. World famous 👨‍🍳 at home. Pro Level Pro-Crastinator. Man child. Dad of (✿◠‿◠)(◠‿◠✿)

No responses yet