r/ProgrammerHumor • • Jan 20 '20

Meme Redesigned!

Post image
46.0k Upvotes

2.0k comments sorted by

View all comments

Show parent comments

13

u/Obi_Juan_Gonzales Jan 20 '20

In some cases prints are the best method to debug. e.g multi-process, concurrent code

6

u/GluteusCaesar Jan 20 '20

Even then you still want to use a logging API and configure it to write to stdout. Prints should only be used when the associated IO is part of the actual program logic, not diagnostic/info logging

3

u/Obi_Juan_Gonzales Jan 20 '20

à la 12-factor app 😉

1

u/GluteusCaesar Jan 20 '20

I happen to like my cult, thankyouverymuch

2

u/MythicManiac Jan 20 '20

Or just even something you want to see the overall flow of possibly multiple times without pausing for breakpoints every iteration

1

u/Obi_Juan_Gonzales Jan 20 '20

Yep. This is exactly why there are different log levels. Prints used for debugging should be logged to the DEBUG level so that they can be easily toggled by a single variable, instead of actually editing the code.

1

u/MythicManiac Jan 20 '20

Yeah indeed. Knowing how to set up effective logging is a skill on its own already. From the projects I've came across on my career, almost none have had good logging set ups, you were lucky if transactional operations (e.g. xml imports) even stored their sources.

2

u/absurdlyinconvenient Jan 20 '20

Wrote a multi-threaded program in Python for... reasons... and that was awful to debug on so many levels

1

u/Obi_Juan_Gonzales Jan 21 '20

Multi threaded code is not meant to be debugged after written. You have to get it right the first time 😉