|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic |
Last Thread Next Thread ![]() |
| Simple STL Logging System |
|
![]() _Sigma Member since: 9/19/2004 From: Saskatoon, Canada |
||||
|
|
||||
| Awesome. Was /just/ starting to think about adding this functionality into my library. Thanks for saving me the trouble of sorting this all out! :) |
||||
|
||||
![]() choffstein Member since: 6/27/2004 From: Boston, MA, United States |
||||
|
|
||||
| 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... |
||||
|
||||
![]() Codeka Member since: 10/19/2008 From: Sydney, Australia |
||||
|
|
||||
Quote: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... |
||||
|
||||
![]() choffstein Member since: 6/27/2004 From: Boston, MA, United States |
||||
|
|
||||
| Interesting -- definitely overlooked that point. Thanks for clarifying. I still think it is a bit intrusive... |
||||
|
||||
![]() brwarner Member since: 12/3/2005 From: Toronto, Canada |
||||
|
|
||||
| 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 |
||||
|
||||
All times are ET (US)![]() |
Last Thread Next Thread ![]() |
|