Boost logo

Boost :

From: Darren Cook (darren_at_[hidden])
Date: 2004-10-28 04:21:36


I'm finding an increasing need for an in-file memory log: specifically when
my program asserts I want to see where it has been.

There are two problems with normal logging, i.e. appending to a disk file:
   * The files get very, very big (I've filled my home partition before)
   * All that writing to disk slows the application down noticeably.

I checked log4cpp and John Torjo's logging library and neither seem to offer
this, but it seems it could fit as one of the logging targets. I had in mind
an object that is a wrapper for e.g. a 1Mb char buffer with the same
interface as std::ostream, so I can just write:
    log_buffer<<"In func1, x="<<x<<", obj="<<obj<<"\n";

And then when my program asserts I can pass log_buffer as a parameter to be
output (requires it to have operator<< defined):
    SMART_ASSERT(y!=1)(y)(log_buffer);

Does anyone know of anything along these lines? Does anyone have the same
need, or just me? I found some circular buffers that nearly do what I want
[1] [2] [3], but they are lower-level as they don't offer the ostream
interface. (In my case I don't need thread-safety.)

Darren

[1]:
http://www.codeguru.com/Cpp/Cpp/cpp_mfc/arrays/article.php/c4013/

[2]:
http://www.codeguru.com/Cpp/Cpp/cpp_mfc/buffers/article.php/c859/

[3]: Thread-safe circular queue, CUJ, June 2004.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk