-2

I'm creating a console program where the user has the option of making the output more verbose when the system processes their requests.

There will always be an output, but the verbose output would be an additional set of printing to the screen.

Making the output more verbose is a setting that they can change. It corresponds with a class variable.

Right now, verbose outputs are printed by using if statements throughout the entire program (essentially "if verbose output is on, print this statement"), but I feel like they are taking up too much space, and could be formatted better.

At the end of the day, I suppose it doesn't matter, but I am inexperienced when working on large programs. Is there a better way than using a slew of if statements related to a class variable?

  • There is no "best" way to do anything and questions of this form only get opinion for responses. You are better off rephrasing your question in terms of possible options to do some specific task such that it could achieve a desired outcome. – Jason K. Jun 8 at 23:48
2

Choose a logging framework for your favourite language and configure it programmatically at startup; among other things, it will provide log levels (thresholds) to discriminate between verbose and non-verbose log entries, allow you avoid boilerplate code like if statements and class variables and provide better formatting.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.