3 ms·
Very interesting. Coming from the java world i'm very perplex at logging with nodejs and still haven't found a solution that makes me feel comfortable: you have
by andretti1977 6y ago
Very interesting. Coming from the java world i'm very perplex at logging with nodejs and still haven't found a solution that makes me feel comfortable: you have to throw errors and analyze the stack to get the calling method or another thing that can happen with winston is that chronological order is not guaranteed
- epegzz 6y agoYeah, NodeJS is indeed lacking some proper introspection functionality :( What I'm doing to get the call stack really is nothing but an ugly hack. And users of this logger even have to do the annoying `log = init(log)` dance to make the hack work. Because if I had put the hack inside the formatter directly I would not have been able to get the actual calling location from the stack trace, as NodeJS is limiting the stack trace length to 10 entries by default, which in this case would be too short. So the strong arguments for JS really aren't its language design and features but rather the fact it can be used universally in backend, frontend and mobile (i.e. allows for code sharing, less context switching during development if you're "fullstack"). Wish there were more languages that would easily support that :)