title: C++ separate member stream overload<<
body: <p>I am looking to write a logger with multiple streams for different severities of logs:</p>
  
  <pre><code>class Logger{
  public:
      std::ostream&amp; errStream;
      std::ostream&amp; warnStream;
  }
  </code></pre>
  
  <p>This way I can use the streams as such:</p>
  
  <pre><code>Logger L;
  L.errStream &lt;&lt; "This is an error message.";
  L.warnStream &lt;&lt; "This is a warning message.";
  </code></pre>
  
  <p>The question is, how can I overload the operator&lt;&lt; for each of the streams separately?  Meaning I want to take different actions based on which stream is written to.</p>
  
  <p>If it helps, I already have member functions for errWrite and warnWrite that take a std::string as the argument:</p>
  
  <pre><code>void errWrite(std::string);
  void warnWrite(std::string);
  </code></pre>
  
  <p>To use these I do:</p>
  
  <pre><code>Logger L;
  L.errWrite("This is an error message.");
  L.warnWrite("This is a warning message.");
  </code></pre>
  
  <p>The trouble with these is that they are not drop in replacements for std::cout and std::cerr, which my code is already filled with.  I was trying to develop something that could easily be dropped into the existing code.  So ultimately I would like either:</p>
  
  <ol>
  <li>A way to overload the operators separately for the different members.</li>
  <li>An alternative approach to what I'm trying to do.</li>
  </ol>
  
  <p>Thanks.</p>