I know (and knew) that there is a node.js debugger, but there are still cases where inserting a console.log statement is the quickest and most practical way to know what's going on. So in my opinion the title of your article should rather be "Stop using console.log ONLY" :-)
Software Developer for as long as I can remember, building startups and projects. I've worked mostly in analytics, devops, and data science research. Running has proved useful so I enjoy doing it.
You know what, with PHP I'm ALWAYS using the debugger, with JS (mostly front end, that is) I keep reverting to console.log ... why? because JS is async and debugging through async code is a pain in the rear.
Also, as soon as JS is being transpiled (Babel and Webpack and so on) it becomes a pain unless you've "mastered" the art of setting up code maps (I'm not even using the proper word I think, that's how far detached I am from this whole thing).
I can't be bothered with that debugger, "console.log" just gets me the answers that I need in a faster and easier way.
Just give me transparent JS debugging without the whole async and transpilation crap, the moment I don't need a degree in theoretical quantum mechanics in order to be smart enough to use the JS debugger then I'll use it.
Software Developer for as long as I can remember, building startups and projects. I've worked mostly in analytics, devops, and data science research. Running has proved useful so I enjoy doing it.
Indeed, another common method I've used for years is just add a number of debug statements and control the level of debug logs with DEBUG=pattern*. Helps for when you need a quick overview of what's happening over time without wanting to step into things. This post is mainly referencing the uncommonly used chrome debugger for nodejs backend code that is available.
How’s it going, I'm a Adam, a Full-Stack Engineer, actively searching for work. I'm all about JavaScript. And Frontend but don't let that fool you - I've also got some serious Backend skills.
Location
City of Bath, UK 🇬🇧
Education
11 plus years* active enterprise development experience and a Fine art degree 🎨
Software Developer for as long as I can remember, building startups and projects. I've worked mostly in analytics, devops, and data science research. Running has proved useful so I enjoy doing it.
Woke up this morning wondering if there was a better way that printing to the console. Wasn't even specifically searching for this, but I am sure glad I found it. Bookmarked and Shared!
Software engineer with 4+ years of experience in building products for numerous domains like fin-tech, real estate, video streaming, retail, and now e-commerce.
This is really helpful for us. Do you know how can we attach debugger to serverless-framework's of lambda functions? I was facing annoying issue with lambda function and it's very hard to put console.log everywhere.
I know (and knew) that there is a node.js debugger, but there are still cases where inserting a
console.logstatement is the quickest and most practical way to know what's going on. So in my opinion the title of your article should rather be "Stop using console.log ONLY" :-)Done! Fixed :)
Champ! :-)
You know what, with PHP I'm ALWAYS using the debugger, with JS (mostly front end, that is) I keep reverting to console.log ... why? because JS is async and debugging through async code is a pain in the rear.
Also, as soon as JS is being transpiled (Babel and Webpack and so on) it becomes a pain unless you've "mastered" the art of setting up code maps (I'm not even using the proper word I think, that's how far detached I am from this whole thing).
I can't be bothered with that debugger, "console.log" just gets me the answers that I need in a faster and easier way.
Just give me transparent JS debugging without the whole async and transpilation crap, the moment I don't need a degree in theoretical quantum mechanics in order to be smart enough to use the JS debugger then I'll use it.
Indeed, another common method I've used for years is just add a number of debug statements and control the level of debug logs with DEBUG=pattern*. Helps for when you need a quick overview of what's happening over time without wanting to step into things. This post is mainly referencing the uncommonly used chrome debugger for nodejs backend code that is available.
Good points,
DEBUG=pattern*has occasionally also worked for me, or putting breakpoints at specific places rather than trying to step into things.I cannot shake this habit. Remove Console then yeah I would use debugger, sometimes I just want to dubug at a glance right in my IDE
I honestly did not know this even existed... Thanks! #LearnSomethingNewEveryDay
No problem! I put stuff like this as a reminder to myself that these sort of tools are there to help. Glad it helps!
Woke up this morning wondering if there was a better way that printing to the console. Wasn't even specifically searching for this, but I am sure glad I found it. Bookmarked and Shared!
This is really helpful for us. Do you know how can we attach debugger to serverless-framework's of lambda functions? I was facing annoying issue with lambda function and it's very hard to put console.log everywhere.
Thx! Very helpful info 👍