OpenMS
2.7.0
|
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 | |
Constructors and Destructors | |
LogStreamBuf (std::string log_level=UNKNOWN_LOG_LEVEL) | |
~LogStreamBuf () override | |
Stream methods | |
int | sync () override |
int | overflow (int c=-1) override |
Static Public Attributes | |
Constants | |
static const time_t | MAX_TIME |
static const std::string | UNKNOWN_LOG_LEVEL |
Friends | |
class | LogStream |
Level methods | |
char * | pbuf_ |
std::string | level_ |
std::list< StreamStruct > | stream_list_ |
std::string | incomplete_line_ |
void | setLevel (std::string level) |
std::string | getLevel () |
void | clearCache () |
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... | |
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... | |
int | syncLF_ () |
Non-lock acquiring sync function called in the d'tor. 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.
struct OpenMS::Logger::LogStreamBuf::LogCacheStruct |
|
explicit |
Create a new LogStreamBuf object and set the level to log_level
log_level | The log level of the LogStreamBuf (default is unknown) |
|
override |
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.
|
override |
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 |
|
override |
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_.
|
protected |
Non-lock acquiring sync function called in the d'tor.
|
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 |