What is good practice for generating verbose output?

前端 未结 5 861
庸人自扰
庸人自扰 2021-02-19 03:49

what is good practice for generating verbose output? currently, i have a function

bool verbose;
int setVerbose(bool v)
{
    errormsg = \"\";
    verbose = v;
           


        
5条回答
  •  暖寄归人
    2021-02-19 04:01

    You can wrap your functionality in a class that supports the << operator which allows you to do something like

    class Trace {
       public:
          enum { Enable, Disable } state;
       // ...
       operator<<(...)
    };
    

    Then you can do something like

    trace << Trace::Enable;
    trace << "deleting interp"
    

提交回复
热议问题