title: Logger system - using levels c++
body: <p>How can I use a function from (Wrap ostream in class and templatize &lt;&lt; operator)</p>
  <p>I want to use SEVERITY levels for the logger and each level can take any number of msg/ elements</p>
  <p>This class accept any number for elements in the object but I need it also for each function in the class
  ex:</p>
  <pre><code>ClassName ClassObject(&amp;std::cout)
  ClassObject.info() &lt;&lt; &quot;test msg&quot; &lt;&lt; 5 &lt;&lt; 10 &lt;&lt; endl;
  </code></pre>
  <p>this is my class</p>
  <pre><code>class logger {
  
  private:
      ostream * str;
  
  public:
  
      logger( ostream* str_v) : str(str_v) {}
  
      template &lt;class T&gt;
      logger&amp; operator&lt;&lt;(T&amp;&amp; x) {
          *str &lt;&lt; std::forward&lt;T&gt;(x);
          return *this;
      }
  
      logger&amp; operator&lt;&lt;(ostream&amp; (*manip)(ostream&amp;)) {
          *str &lt;&lt; manip;
          return *this;
      }
  
      void info(){
          cout &lt;&lt;&quot;hello world&quot;&lt;&lt;endl;
      }
  };
  
  int main(){
  
     logger l(&amp;std::cout);
      l &lt;&lt; 5 &lt;&lt; std::string(&quot; test&quot;)&lt;&lt;endl;
     //I want to use info like that
     l.info() &lt;&lt; &quot;print anything&quot; &lt;&lt; 5 &lt;&lt; endl;
  
      return 0;
  
  }
  </code></pre>