#include <logStream.h>
Public Types | |
Enums | |
enum | LogStreamLevel { ERROR_LEVEL = 2000, WARNING_LEVEL = 1000, INFORMATION_LEVEL = 0 } |
Log levels. More... | |
Public Member Functions | |
Constructors and Destructors | |
LogStream (LogStreamBuf *buf=0, bool delete_buf=true, bool associate_stdio=false) | |
Constructor. | |
virtual | ~LogStream () |
Destructor. | |
Stream Methods | |
LogStreamBuf * | rdbuf () |
rdbuf method of ostream. | |
LogStreamBuf * | operator-> () |
Arrow operator. | |
Loglevel management | |
void | setLevel (int level) |
Assign a new log level. | |
int | getLevel () |
Return the current log level. | |
LogStream & | level (int level) |
Set a temporary log level. | |
LogStream & | info (int n=0) |
Log an information message. | |
LogStream & | error (int n=0) |
Log an error message. | |
LogStream & | warn (int n=0) |
Log an information message. | |
Associating Streams | |
void | insert (std::ostream &s, int min_level=LogStreamBuf::MIN_LEVEL, int max_level=LogStreamBuf::MAX_LEVEL) |
Associate a new stream with this logstream. | |
void | remove (std::ostream &s) |
Remove an association with a stream. | |
void | insertNotification (std::ostream &s, LogStreamNotifier &target, int min_level=LogStreamBuf::MIN_LEVEL, int max_level=LogStreamBuf::MAX_LEVEL) |
Add a notification target. | |
void | setMinLevel (const std::ostream &s, int min_level) |
Set the minimum log level of an associated stream. | |
void | setMaxLevel (const std::ostream &s, int max_level) |
Set the maximum log level of an associated stream. | |
void | setPrefix (const std::ostream &s, const string &prefix) |
Set prefix for output to this stream. | |
void | disableOutput () throw () |
Disable all output. | |
void | enableOutput () throw () |
Enable all output. | |
bool | outputEnabled () const throw () |
Is Output enabled? | |
void | flush () throw () |
Message Buffer Management | |
void | clear () |
Clear the message buffer. | |
Size | getNumberOfLines (int min_level=LogStreamBuf::MIN_LEVEL, int max_level=LogStreamBuf::MAX_LEVEL) const |
Return the number of lines. | |
string | getLineText (const Index &index) const |
Return the text of a specific line. | |
Time | getLineTime (const Index &index) const |
Return the log time of a specific line. | |
int | getLineLevel (const Index &index) const |
Return the log level of a specific line. | |
list< int > | filterLines (int min_level=LogStreamBuf::MIN_LEVEL, int max_level=LogStreamBuf::MAX_LEVEL, Time earliest=0, Time latest=LogStreamBuf::MAX_TIME, const string &s="") const |
Retrieve a list of indices of lines that match certain criteria. |
|
Log levels. Constants for the different predefined log levels. Use ERROR to indicate a severe error, WARNING to indicate a problem that could be fixed or is of minor importance, and INFORMATION for messages that do not indicate any problem (e.g. progress messages). |
|
Constructor.
Creates a new LogStream object that is not associated with any stream. If the argument
|
|
Destructor. Clears all message buffers. |
|
Clear the message buffer. This method removes all stored messages from the message buffer. |
|
Log an error message. This method is equivalent to level (LogStream::ERROR + n).
|
|
Retrieve a list of indices of lines that match certain criteria. If a criterion is left empty, it is not used.
|
|
Return the current log level.
The LogStreamBuf object has an internal current log level (
|
|
Return the log level of a specific line. If the given line does not exists, {-1} is returned.
|
|
Return the text of a specific line. This method returns the content of a specific message without time and level.
|
|
Return the log time of a specific line.
|
|
Return the number of lines. This method retruns the number of lines in the buffer for a given range of levels.
|
|
Log an information message. This method is equivalent to level (LogStream::INFORMATION + n).
|
|
Associate a new stream with this logstream.
This method inserts a new stream into the list of associated streams and sets the corresponding minimum and maximum log levels. Any message that is subsequently logged, will be copied to this stream if its log level is between
|
|
Set a temporary log level. Using level, a temporary loglevel may be defined. It is valid unly until the next flush or endl is issued.
|
|
Arrow operator.
|
|
This method is needed to access the LogStreamBuf object. |
|
Remove an association with a stream. Remove a stream from the stream list and avoid the copying of new messages to this stream.
|
|
Assign a new log level. This method assigns a new loglevel which will be used for all messages sent to the LogStream after that call (except for messages which use the temporary loglevel set by level ). |
|
Set the maximum log level of an associated stream. This method changes the maximum log level of an already associated stream. However, if the stream is not associated, nothing will happen.
|
|
Set the minimum log level of an associated stream. This method changes the minimum log level of an already associated stream. However, if the stream is not associated, nothing will happen.
|
|
Set prefix for output to this stream. Each line written to the stream will be prefixed by this string. The string may also contain trivial format specifiers to include loglevel and time/date of the logged message.
|
|
Log an information message. This method is equivalent to level (LogStream::WARNING + n).
|