List of all members.
Detailed Description
Stream buffer used by LogStream.
This class implements the low level behavior of LogStream . It takes care of the buffers and stores the lines written into the LogStream object. It also contains a list of streams that are associated with the LogStream object. This list contains pointers to the streams and their minimum and maximum log level. Each line entered in the LogStream is marked with its time (in fact, the time LogStreamBuf::sync was called) and its loglevel. The loglevel is determined by either the current loglevel (as set by LogStream::setLevel or a temporary level (as set by LogStream::level for a single line only). For each line stored, the list of associated streams is checked whether the loglevel falls into the range declared by the stream's minimum and maximum level. If this condition is met, the logline (with its prefix, see LogStream::setPrefix ) is also copied to the associated stream and this stream is flushed, too.
Constructor & Destructor Documentation
Create a new LogStreamBuf object and set the level to log_level
- Parameters:
-
| log_level | The log level of the LogStreamBuf (default is unknown) |
Destruct the buffer and free all stored messages strings.
Member Function Documentation
| std::string addToCache_ |
( |
std::string const & |
line |
) |
[protected] |
Adds the new line to the cache and removes an old one if necessary
- Parameters:
-
| line | The Log message that should be added to the cache |
- Returns:
- An additional massage if a reoccuring message was removed from the cache
Checks if some of the cached entries where sent more then once to the LogStream and (if necessary) prints a corresponding messages into all affected Logs
| void distribute_ |
( |
std::string |
outstring |
) |
[protected] |
Distribute a new message to connected streams.
| std::string expandPrefix_ |
( |
const std::string & |
prefix, |
|
|
time_t |
time | |
|
) |
| | const [protected] |
Interpret the prefix format string and return the expanded prefix.
| Size getNextLogCounter_ |
( |
|
) |
[protected] |
Returns the next free index for a log message.
| bool isInCache_ |
( |
std::string const & |
line |
) |
[protected] |
Checks if the line is already in the cache.
| virtual int overflow |
( |
int |
c = -1 |
) |
[virtual] |
This method calls sync and streambuf::overflow(c) to prevent a buffer overflow.
| void setLevel |
( |
std::string |
level |
) |
|
| virtual int sync |
( |
|
) |
[virtual] |
This method is called as soon as the ostream is flushed (especially this method is called by flush or endl). It transfers the contents of the streambufs putbuffer into a logline if a newline or linefeed character is found in the buffer ("\n" or "\r" resp.). The line is then removed from the putbuffer. Incomplete lines (not terminated by "\n" / "\r" are stored in incomplete_line_.
Friends And Related Function Documentation
Member Data Documentation
std::string level_ [protected] |
Cache of the last two log messages.
Sequential counter to remember the sequence of occurence of the cached log messages
Cache of the occurence sequence of the last two log messages.