Presuming Java, and that you're determined to do this yourself rather than use a proper logging facility, I'd prefer to see something like:
outPort.println("Hello world");
... where outPort
defaults to a null object unless you passed in something like:
someFunction(System.out);
... to override the default.
Now sure, you could just reconfigure System.out
or redirect output when you run the program, but that's all or nothing. If you have 15 objects that talk but you only want to hear from one of them it's nice if you can just tell each of them what to talk to.
You can send output to "/dev/null" or "NUL:" if you know your OS. But if you want to not care here's a quick and dirty version of a null object that will stop the noise before it ever gets magic file names involved.
java.io.PrintStream outPort = new java.io.PrintStream(
new java.io.OutputStream() { @Override public void write(int b){} }
);
This null object does nothing quietly when called. It's a good default if quiet is your desired typical behavior. Here I'm using an anonymous class because I'm lazy. You can make a more robust class and give it a proper name if you like.
These tricks work in most languages if you change the right names.
-v
/--verbose
is the standard name for a command line flag that does the same thing.