What is the proper name for doing debugging by adding 'print' statements
Yes - it's known as printf()
debugging, named after the ubiquitous C function:
Used to describe debugging work done by inserting commands that output more or less carefully chosen status information at key points in the program flow, observing that information and deducing what's wrong based on that information.
-- printf() debugging@everything2
Native users of other languages no doubt refer to it by the default print / log / or trace command available for their coding platform of choice, but i've heard the "printf()" name used to refere to this technique in many languages other than C. Perhaps this is due to its history: while BASIC and FORTRAN had basic but serviceable PRINT
commands, C generally required a bit more work to format various data types: printf()
was (and often still is) by far the most convenient means to this end, providing many built-in formatting options. Its cousin, fprintf()
, takes another parameter, the stream to write to: this allowed a careful "debugger" to direct diagnostic information to stderr
(possibly itself redirected to a log file) while leaving the output of the program uncorrupted.
Although often looked down on by users of modern debugging software, printf() debugging continues to prove itself indispensable: the wildly popular FireBug tool for the Firefox web browser (and similar tools now available for other browsers) is built around a console window into which web page scripts can log errors or diagnostic messages containing formatted data.
I've heard it called Caveman Debugging
I thought the following quote would be apropos:
"The most effective debugging tool is still careful thought, coupled with judiciously placed print statements."
— Brian Kernighan, "Unix for Beginners" (1979)