title: Add time stamp with std::cout
body: <p>I have the following code which is redirecting my <code>std::cout</code> output to a log file.</p>
  
  <pre><code>std::ofstream out("out.txt");
  std::streambuf *coutbuf = std::cout.rdbuf(); //save old buf
  std::cout.rdbuf(out.rdbuf()); //redirect std::cout to out.txt!
  </code></pre>
  
  <p>Now what I want is that whenever a newline is occurring, then the current <strong>time stamp</strong> will be written to the file.</p>
  
  <p>I know I can achive this with:</p>
  
  <pre><code>std::cout &lt;&lt; getTime() &lt;&lt; "printing data" &lt;&lt; std::endl;
  </code></pre>
  
  <p>But what I want is that of <code>std::cout</code> taking care of it automatically somehow. Is that possible?</p>