I'm looking for some best practice advice here. I have a library that I'd like to add some debug code into (think System.out.println) that only gets executed if a flag is set in a configuration file.
This is fairly trivial and will have the desired output for helping debug the program as I go along. That being said it seems heavy handed in that I'll have a lot of if(DEBUG) statements floating around my production code. I'm less worried about the efficiency of the code and more about the readability in terms of the statements that actually do something vs those that are just their for debugging.
I understand that with most IDEs I could simply step through the code to effectively give myself a more manual debugging option, but I've found for any code base that is sufficiently iterative that method is more of a pain than just dumping things to the console. I suppose another option could be to use a logging framework that has a DEBUG setting, but I still feel like the extra logging instructions would be just as ugly as just shipping them to the console.
Are there any options I'm missing here? Are their debugging frameworks in Java that make this cleaner? For point of reference I'd like to know when some specific methods get called and the string representation of various objects at different points in the execution.
Thanks in advance.