BALL::LogStream Class Reference
#include <BALL/COMMON/logStream.h>
List of all members.
Public Types |
|
|
enum | LogStreamLevel { ERROR_LEVEL = 2000,
WARNING_LEVEL = 1000,
INFORMATION_LEVEL = 0
} |
Public Member Functions |
|
|
| LogStream (LogStreamBuf *buf=0, bool delete_buf=true, bool associate_stdio=false) |
virtual | ~LogStream () |
|
|
LogStreamBuf * | rdbuf () |
LogStreamBuf * | operator-> () |
|
|
void | setLevel (int level) |
int | getLevel () |
LogStream & | level (int level) |
LogStream & | info (int n=0) |
LogStream & | error (int n=0) |
LogStream & | warn (int n=0) |
|
|
void | insert (std::ostream &s, int min_level=LogStreamBuf::MIN_LEVEL, int max_level=LogStreamBuf::MAX_LEVEL) |
void | remove (std::ostream &s) |
void | insertNotification (std::ostream &s, LogStreamNotifier &target, int min_level=LogStreamBuf::MIN_LEVEL, int max_level=LogStreamBuf::MAX_LEVEL) |
void | setMinLevel (const std::ostream &s, int min_level) |
void | setMaxLevel (const std::ostream &s, int max_level) |
void | setPrefix (const std::ostream &s, const string &prefix) |
void | disableOutput () |
| Disable all output.
|
void | enableOutput () |
| Enable all output.
|
bool | outputEnabled () const |
| Is Output enabled?
|
void | flush () |
|
|
void | clear () |
Size | getNumberOfLines (int min_level=LogStreamBuf::MIN_LEVEL, int max_level=LogStreamBuf::MAX_LEVEL) const |
string | getLineText (const Index &index) const |
Time | getLineTime (const Index &index) const |
int | getLineLevel (const Index &index) const |
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 |
Private Types |
typedef std::list
< LogStreamBuf::StreamStruct >
::iterator | StreamIterator |
Private Member Functions |
StreamIterator | findStream_ (const std::ostream &stream) |
bool | hasStream_ (std::ostream &stream) |
bool | bound_ () const |
Private Attributes |
bool | delete_buffer_ |
bool | disable_output_ |
Detailed Description
Log Stream Class.
Definition at line 256 of file logStream.h.
Member Typedef Documentation
Member Enumeration Documentation
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).
- Enumerator:
ERROR_LEVEL |
Loglevels >= ERROR should be used to indicate errors
|
WARNING_LEVEL |
Loglevels >= WARNING should be used to indicate warnings
|
INFORMATION_LEVEL |
Loglevels >= INFORMATION indicate information messages
|
Definition at line 273 of file logStream.h.
Constructor & Destructor Documentation
BALL::LogStream::LogStream |
( |
LogStreamBuf * |
buf = 0 , |
|
|
bool |
delete_buf = true , |
|
|
bool |
associate_stdio = false | |
|
) |
| | |
Constructor. Creates a new LogStream object that is not associated with any stream. If the argument associate_stdio
is set to true, cout
is associated with all messages of levels INFORMATION and WARNING , and cerr
is associated with all messages of level ERROR .
- Parameters:
-
| buf | |
| delete_buf | |
| associate_stdio | bool, default is false |
virtual BALL::LogStream::~LogStream |
( |
|
) |
[virtual] |
Destructor. Clears all message buffers.
Member Function Documentation
bool BALL::LogStream::bound_ |
( |
|
) |
const [private] |
void BALL::LogStream::clear |
( |
|
) |
|
Clear the message buffer. This method removes all stored messages from the message buffer.
void BALL::LogStream::disableOutput |
( |
|
) |
|
void BALL::LogStream::enableOutput |
( |
|
) |
|
LogStream& BALL::LogStream::error |
( |
int |
n = 0 |
) |
|
Log an error message. This method is equivalent to level (LogStream::ERROR + n).
- Parameters:
-
Retrieve a list of indices of lines that match certain criteria. If a criterion is left empty, it is not used.
- Parameters:
-
| min_level | the minimum level of messages |
| max_level | the maximum level of messages |
| earliest | (long) the time of messages to start filtering |
| latest | (long) the time of messages to stop filtering |
| s | a string to look for |
StreamIterator BALL::LogStream::findStream_ |
( |
const std::ostream & |
stream |
) |
[private] |
void BALL::LogStream::flush |
( |
|
) |
|
int BALL::LogStream::getLevel |
( |
|
) |
|
Return the current log level. The LogStreamBuf object has an internal current log level (level_
). It is set to 0 by the LogStreamBuf default constructor. This method returns rdbuf()->level_
if rdbuf() does not return a null pointer, 0 otherwise.
- Returns:
- int the current log level
int BALL::LogStream::getLineLevel |
( |
const Index & |
index |
) |
const |
Return the log level of a specific line. If the given line does not exists, {-1} is returned.
- Parameters:
-
| index | the index of the message |
- Returns:
- int the level
string BALL::LogStream::getLineText |
( |
const Index & |
index |
) |
const |
Return the text of a specific line. This method returns the content of a specific message without time and level.
- Returns:
- string the text of the message
- Parameters:
-
| index | the index of the line |
Time BALL::LogStream::getLineTime |
( |
const Index & |
index |
) |
const |
Return the log time of a specific line
- Parameters:
-
| index | the index of the messages |
- Returns:
- Time the time of the message
Return the number of lines. This method retruns the number of lines in the buffer for a given range of levels.
- If the range is omitted, the total number of messages is returned.
- Returns:
- Size the number of lines matching the log level range
- Parameters:
-
| min_level | the minimum log level for the counted messages |
| max_level | the maximum log level for the counted messages |
bool BALL::LogStream::hasStream_ |
( |
std::ostream & |
stream |
) |
[private] |
LogStream& BALL::LogStream::info |
( |
int |
n = 0 |
) |
|
Log an information message. This method is equivalent to level (LogStream::INFORMATION + n).
- Parameters:
-
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 min_level
and max_level
. If min_level
and max_level
are omitted, all messages are copied to this stream. If min_level
and max_level
are equal, this function can be used to listen to a specified channel.
- Parameters:
-
| s | a reference to the stream to be associated |
| MIN_LEVEL | the minimum level of messages copied to this stream |
| MAX_LEVEL | the maximum level of messages copied to this stream |
Add a notification target
LogStream& BALL::LogStream::level |
( |
int |
level |
) |
|
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.
- Use this command to log a single line with a certain log level.
- Example:
log << "log message 1" << endl;
log.level(4) << "log message 2" << endl;
log << "log message 3" << endl;
- In this example, only the second message will be logged using level 4.
- Returns:
- LogStream the log stream
- Parameters:
-
| level | the temporary log level |
bool BALL::LogStream::outputEnabled |
( |
|
) |
const |
rdbuf
method of ostream. This method is needed to access the LogStreamBuf object.
void BALL::LogStream::remove |
( |
std::ostream & |
s |
) |
|
Remove an association with a stream. Remove a stream from the stream list and avoid the copying of new messages to this stream.
- If the stream was not in the list of associated streams nothing will happen.
- Parameters:
-
| s | the stream to be removed |
void BALL::LogStream::setLevel |
( |
int |
level |
) |
|
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 ).
void BALL::LogStream::setMaxLevel |
( |
const std::ostream & |
s, |
|
|
int |
max_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.
- Parameters:
-
| s | the associated stream |
| max_level | the new minimum level |
void BALL::LogStream::setMinLevel |
( |
const std::ostream & |
s, |
|
|
int |
min_level | |
|
) |
| | |
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.
- Parameters:
-
| s | the associated stream |
| min_level | the new minimum level |
void BALL::LogStream::setPrefix |
( |
const std::ostream & |
s, |
|
|
const string & |
prefix | |
|
) |
| | |
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.
- The following format tags are recognized:
- l loglevel
- y message type ("Error", "Warning", "Information", "-")
- T time (HH:MM:SS)
- t time in short format (HH:MM)
- D date (DD.MM.YYYY)
- d date in short format (DD.MM.)
- S time and date (DD.MM.YYYY, HH:MM:SS)
- s time and date in short format (DD.MM., HH:MM)
- %% percent sign (escape sequence)
LogStream& BALL::LogStream::warn |
( |
int |
n = 0 |
) |
|
Log an information message. This method is equivalent to level (LogStream::WARNING + n).
- Parameters:
-
Member Data Documentation