std::endl Usage
Writing std::endl to a stream has the following effect: it writes Enter to the stream and flushes it. This is very important: flushing makes sure the data is written from the buffer to its real destination. By handling the flushing, you can do very nifty things. For instance, you can create a log file class that automatically precedes every written message with the time it's been written. Or, in this particular case, you can make sure the message is written to our two internal logs.
Note that handling flush is not as easy as it looks. You don't handle flush directly. (It's not a virtual function.) You have to create your stream buffer class, derived directly or indirectly from std::basic_streambuf< ...>. Then, you must override the virtual function int sync.
Download the source code from the CUJ website (available at <www.cuj.com/code>) and analyze the CMessageHandlerStream and CMessageHandler_streambuf classes for more details.