   Simple STL Logging System
  Comments for the article Simple STL Logging System
  Awesome. Was /just/ starting to think about adding this functionality into my library. Thanks for saving me the trouble of sorting this all out! :)   ;  Liked it, but why not hack the scoped_lock within the write function itself?  Then you don't have issues with forgetting to lock/unlock and you still get thread safety...   ;Quote:Original post by visageLiked it, but why not hack the scoped_lock within the write function itself? Then you don't have issues with forgetting to lock/unlock and you still get thread safety...No you don't. The problem is that the ostream has an internal buffer which it uses until flush() is called (e.g. until std::endl is written) and that buffer can get overwritten by multiple threads before you even get into the write method.I've fixed it in my own code by wrapping my osteam object in a thread-local container (using boost::thread_specific_ptr). Perhaps I should post the code I used...   ;  Interesting -- definitely overlooked that point.  Thanks for clarifying.  I still think it is a bit intrusive...   ;  Yes I ran into that problem with the buffering resulting in having to lock the mutex outside the calls. If someone (I saw mentioned above) has code that works, please post. I would be interested to see how it was done   