3 ms·
In typescript dev I made “console.log” a linting error that cannot be merged. The occasional legitimate need uses console.info I think print debugging is fine.
by Waterluvian 2y ago
In typescript dev I made “console.log” a linting error that cannot be merged. The occasional legitimate need uses console.info
I think print debugging is fine. It has a time and place. But ideally find a way to protect yourself from accidentally leaving it in. It’s such an easy mistake to make.
- mort96 2y agoWell this is an instance of writing to a file, so the JS equivalent would be calling .write on a file stream. Not exactly comparable, it wasn't literally a debug print() that someone had forgotten to delete but a log file that was enabled when verbose logging was enabled.
- theamk 2y agoin similar situations, instead of saying "VERBOSE=1", I say "VERBOSE=getenv("MY_NAME_MY_APP_VERBOSE") == '1'", and set this env variable in my terminal when needed. This way there is zero chance I commit verbose-enabled debug code.
- orliesaurus 2y agonot a typescript dev here: what do you use instead of console.log for debugging?
- darknavi 2y agoIt sounds like they use console.log, but they don't let it ship in their production code.
- electromech 2y agoI liked tslog last time I tried it.
- Waterluvian 2y agoconsole.log is reserved for devtime debugging and is a linting error so it cannot be left in. console.info is used in the occasional time we actually want to write things to console (along with console.warn, console.error, console.group, console.table, etc.). It's all it took. Just making a clear distinction between the two and communicating it with the team.