Whenever I want to debug something, I use print statements and then delete them when I am done, because otherwise too much information is printed to the terminal. But then at some point in the future, I might want the same print statement to debug something else, so I end up rewriting the same print statement, only to delete it again.
Is there any way around this problem, so that I do not have to keep rewriting print statements? I think log levels are an attempt to address this problem, but I never found them to be of any use, because the "DEBUG" log level very quickly becomes so verbose that it becomes useless.
One idea I had as I was writing this is to give each log statement an identifier (e.g. "log(int identifier, string statement)"), and then at runtime you can select which log statement is enabled by writing to a variable or perhaps a list, specifying the identifier(s) of the log statements you want printed.
That is basically what I do, but for things that are cumbersome to recompile/restart, it would be nice to have some flexibility at runtime over what you log. Imagine someone complains about a bug in some feature in your software, and then you go into a GUI interface, and and enter an identifier to enable logging of the loop you suspect the bug being in. That would be kind of cool.