i quit using console.log in prod

preview_player
Показать описание
I quit using JavaScript console log in production because people were making fun of me. Now I use eslint for warnings and VS Code logpoints to avoid them altogether.

#shorts #javascript #learntocode
Рекомендации по теме
Комментарии
Автор

So in conclusion: don't do console log, do console log with extra steps

crysist
Автор

The true power of VS Code is beyond our understanding.

ShashotoANur
Автор

At this point I think that there is a place deep in Microsoft chambers, that breeds programmers and test them, and the top 1% are selected to program VSCode, and the worst 1% are selected to program Windows

andresramos
Автор

To avoid console.log, use alert()

/s

bloosrpent
Автор

We're designing pages for the vast majority of people who don't know the console log exists. If a coder would actually look at the log and laugh at it, hiding the log would just make them find something else to laugh at

DannyBPlays
Автор

wait, are people "ashamed" of using console.log as JS frontend developers? How come i didnt get the memo?

realSeyitan
Автор

console.log('stop 1');
console.log('stop 2');
console.log('stop 3');
console.log('stop 4');

"ah, so the problem is before "stop 3"

beinyourguard
Автор

Can't change the habit of a lifetime :P

jamesgrimshaw
Автор

3. Tell webpack to bundle without console.log

sDiovliFR
Автор

Or, use terser with webpack to automatically filter out console.log in the production build, whilst keeping them in dev/live builds

madssrensen
Автор

The problem is that the logpoints move when you modify the code, so they are not reliable to stay longer term where you put them.

santiagopuentep
Автор

Logging is a good tool, especially in production, you don't wanna end up with a lot of debug messages, while error messages get lost in the stream of logs. Never knew JS had functionality for this. Thank u!

nitroflap
Автор

I generally just write a utility class for it that just wraps these things (also allows me to use stuff like timestamping and easy to read formats).
One of the methods is "debug()" which adds a check whether we are running in debug or not (if not, it'll obviously just return without printing anything).

FinlayDaGk
Автор

Also, have an idea for the next video: ssl and tls in 100 seconds.

nitroflap
Автор

I think the title is a bit misleading, intentional logging is really useful in production to track production bugs specially in the backend for the front end you can also capture those logs with tools like sentry . Development logging is the one that is embarrassing and messy

EstebanCodes
Автор

I ususally write a small wrapper class which checks the environment and doesnt log in production. Easy and simple.

ellion
Автор

The best console log I've seen was someone outputting an outline of Mario.

Xaero
Автор

Crazy how you have to watch a 20sec ad for a 30sec video

Siskofx
Автор

"Careful thought coupled with print statements is still the best debugger"

heanz
Автор

In unreal engine you can mark things as "editor only" and they won't appear in the packaged game. Some stuff like prints is always editor only so you never have to clean it up

blackhole