Setting a global "if (!verbose) then (ignore all printlns)"

Advertisement
In my program I use many System.out.printlns to mark where I am in the excecution of the program, what the current states are, etc. This makes it easy to understand problems if an error occurs even when I'm not in a debug mode. In my current program I probably have about 100 of these flags.
Is there any way that I can set up some kind of global system such that only if my 'verbose' flag is true will any System.out.printlns get excecuted? If verbose is not true, then these should all be ignored. Is that possible?
That is, I'd prefer not to have to type out every time
if (verbose)
   System.out.println("Initializing main testing engine");Any recommendations appreciated.
Advertisement

Replay

First, let me say: this isnt a competition.
I was in no way trying to contradict your advice.
(1) I said "for small home projects where I wouldnt use a Log API"
(2) I said i use a proper logging API at work.
I was merely pointing out a VERY simple alternative given different
circumstances (a small informal project).
As for:
"ahm... it's already in the JDK. you don't need to add or configure anything."
Just reading the intro paragraph to that package gives me a headache.
It is:
"The JavaTM Logging APIs, introduced in package java.util.logging, facilitate software servicing and maintenance at customer sites by producing log reports suitable for analysis by end users, system administrators, field service engineers, and software development teams. The Logging APIs capture information such as security failures, configuration errors, performance bottlenecks, and/or bugs in the application or platform. The core package includes support for delivering plain text or XML-formatted log records to memory, output streams, consoles, files, and sockets. In addition, the logging APIs are capable of interacting with logging services that already exist on the host operating system."
I dont want any of that noise following me home! : )