Stream buffer used by LogStream. More...
#include <OpenMS/CONCEPT/LogStream.h>
Classes | |
struct | LogCacheStruct |
Holds a counter of occurrences and an index for the occurrence sequence of the corresponding log message. More... | |
struct | StreamStruct |
Holds a stream that is connected to the LogStream. It also includes the minimum and maximum level at which the LogStream redirects messages to this stream. More... | |
Public Member Functions | |
void | clearCache () |
Constructors and Destructors | |
LogStreamBuf (std::string log_level=UNKNOWN_LOG_LEVEL) | |
virtual | ~LogStreamBuf () |
Stream methods | |
virtual int | sync () |
virtual int | overflow (int c=-1) |
Level methods | |
void | setLevel (std::string level) |
std::string | getLevel () |
Static Public Attributes | |
Constants | |
static const time_t | MAX_TIME |
static const std::string | UNKNOWN_LOG_LEVEL |
Protected Member Functions | |
void | distribute_ (std::string outstring) |
Distribute a new message to connected streams. More... | |
std::string | expandPrefix_ (const std::string &prefix, time_t time) const |
Interpret the prefix format string and return the expanded prefix. More... | |
Protected Attributes | |
char * | pbuf_ |
std::string | level_ |
std::list< StreamStruct > | stream_list_ |
std::string | incomplete_line_ |
Friends | |
class | LogStream |
Caching | |
Size | log_cache_counter_ |
std::map< std::string, LogCacheStruct > | log_cache_ |
Cache of the last two log messages. More... | |
std::map< Size, std::string > | log_time_cache_ |
Cache of the occurrence sequence of the last two log messages. More... | |
bool | isInCache_ (std::string const &line) |
Checks if the line is already in the cache. More... | |
std::string | addToCache_ (std::string const &line) |
Size | getNextLogCounter_ () |
Returns the next free index for a log message. More... | |
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.
|
explicit |
Create a new LogStreamBuf object and set the level to log_level
log_level | The log level of the LogStreamBuf (default is unknown) |
|
virtual |
Destruct the buffer and free all stored messages strings.
|
protected |
Adds the new line to the cache and removes an old one if necessary
line | The Log message that should be added to the cache |
void clearCache | ( | ) |
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
|
protected |
Distribute a new message to connected streams.
|
protected |
Interpret the prefix format string and return the expanded prefix.
std::string getLevel | ( | ) |
Returns the LogLevel of this LogStream
|
protected |
Returns the next free index for a log message.
|
protected |
Checks if the line is already in the cache.
|
virtual |
This method calls sync and streambuf::overflow(c)
to prevent a buffer overflow.
void setLevel | ( | std::string | level | ) |
Set the level of the LogStream
level | The new LogLevel |
|
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_.
|
friend |
|
protected |
|
protected |
|
protected |
Cache of the last two log messages.
|
protected |
Sequential counter to remember the sequence of occurrence of the cached log messages
|
protected |
Cache of the occurrence sequence of the last two log messages.
|
static |
|
protected |
|
protected |
|
static |
OpenMS / TOPP release 2.3.0 | Documentation generated on Tue Jan 9 2018 18:22:15 using doxygen 1.8.13 |