Are you printing things for effect? For example, you’re building a command-line tool and this forms part of the output. Or is your printing just for debugging purposes?
If it’s the former I’d change how you write your code. I tend to build my tools so that I have core code that returns a description of what the results should be, and then I have separate code to print that. This has a bunch of advantages:
It separates concerns, which is always a good thing
It allows the core code to be reused in other environments, like in a GUI app.
It helps with testing.
My core code tends to be functional — that is, its output is predictable based on solely its input parameters — which means I can see everything in the debugger.
It means I don’t have to worry about this problem (-:
In contrast, if these
print statements are purely for debugging, I’m going to recommend that you take a look at Xcode’s breakpoints. You can set up a breakpoint that prints some state and then automatically continues. The Xcode UI then makes it easy to enable and disable these breakpoints, and thus enable and disable your logging.
For some great examples of the power of Xcode breakpoints, check out WWDC 2018 Session 412 Advanced Debugging with Xcode and LLDB.
Share and Enjoy
Quinn “The Eskimo!” @ DTS @ Apple