Live data from Hacker News

You say “cave dweller debugging”, I say debug logging

sicpers.info

21–30 of 139 posts

Re: You say “cave dweller debugging”, I say debug logging

#21
post #19

when outputting lots of information (like a running game) i found that a "csv-like" format is actually the best compromise between readability and being structured. Just log "header_1;header2;... value_1;value_2;..." you can still grep it, or redirect to a file and parse later

in Javascript applications, you can use `console.table()`: https://developer.mozilla.org/en-US/docs/Web/API/console/tab...

Re: You say “cave dweller debugging”, I say debug logging

#25

No doubt there is a place (or indeed a need) for debug (or trace) logging in environments where you can’t simply pause execution. However, in development environments you would be foolish not to use the (vastly superior) tooling available. I think many developers shy away from debuggers simply because they haven't taken the time to understand how to use them effectively, whereas everyone knows how to write a log stat…

I know your list is not intended to be exhaustive, but it's missing my main reason for using print: because the debugger can be really slow (at least in Python).

For some operations, running them in debug mode means they are 10 times slower, turning a 30sec operation (such as parsing big files into memory) into 5 minutes. If I'm relatively certain of what the problem is and I solve it in less than ~5 tries, I saved time.

Re: You say “cave dweller debugging”, I say debug logging

#27
post #11

Earlier quoted context omitted.

If you can show me a debugger that will work on a PHP application in the Symfony framework, runs on Mac, and is not built on Eclipse or a similar lumbering monstrosity, I will gladly give it a try. (Hell, I tried PHPStorm, but it's just so painful to use...) Until and unless such a thing appears, debug logging is pretty much what I've got. (And given the complexity of the project in question, and the fact that I'm ba…

I dont personally use PHP so I cant really vouch for it, but I just asked a friend and he uses Xdebug in vscode (on an M1 mac).

Hm. I'll give that a try and see if it's worthwhile. Thanks.

Re: You say “cave dweller debugging”, I say debug logging

#28
post #17

No doubt there is a place (or indeed a need) for debug (or trace) logging in environments where you can’t simply pause execution. However, in development environments you would be foolish not to use the (vastly superior) tooling available. I think many developers shy away from debuggers simply because they haven't taken the time to understand how to use them effectively, whereas everyone knows how to write a log stat…

There are two situations that I encounter that make step through debugging difficult or impossible, and for a lot of my work both apply. A) When developing for a microcontroller (however large or small). Stepping debuggers are limited, and sometimes unavailable at all. Most are clunky. ARM is the best here. B) Running real time things. E.g. you can't step through a Bluetooth comms process because the moment you hit a…

I will add

C) debugging signal handlers is somewhere between tricky and impossible depending on the scenario because of how debuggers work.

D) debugging optimized code. -O2 or -O3 code will have everything executing out of order, all variables are optimizes out, everything is inlined, etc.

Re: You say “cave dweller debugging”, I say debug logging

#29
post #7

I'm having the same issues... Although I'm not a full time developer, I do some small coding and I'm also sort of responsible for the dev team. I rarely use a debugger. I do most of debugging through logging. There are 2 advantages that I see: - it forces me to add the logs where they are needed to understand the flow of the application - it forces me to make those logs actually usable, readable and understandable De…

> Making logs during development also forces developers to make a conscious effort of finding a balance of what and when to log something, create proper debug levels not to overwhelm the logs, while still providing some useful information...

The need for this balance is why I don't completely agree with the article.

If I'm debugging something with log messages, I put way more detail into it than I want to see in production even at LogLevel.DEBUG.

Post reply on HN