#include <logStream.h>
Inherits std::ostream.
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 () |
Disable all output. |
|
void | enableOutput () |
Enable all output. |
|
bool | outputEnabled () const |
Is Output enabled? |
|
void | flush () |
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).
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
.
buf | ||
delete_buf | ||
associate_stdio | bool, default is false |
virtual BALL::LogStream::~LogStream | ( | ) | [virtual] |
Destructor.
Clears all message buffers.
void BALL::LogStream::clear | ( | ) |
Clear the message buffer.
This method removes all stored messages from the message buffer.
LogStream& BALL::LogStream::error | ( | int | n = 0 |
) |
Log an error message.
This method is equivalent to level (LogStream::ERROR + n).
n | the channel |
Referenced by BALL::AssignBondOrderProcessor::getNumberOfAddedHydrogens(), BALL::AssignBondOrderProcessor::getTotalCharge(), BALL::AssignBondOrderProcessor::getTotalPenalty(), BALL::VIEW::Renderer::renderBox_(), BALL::VIEW::Renderer::renderDisc_(), BALL::VIEW::Renderer::renderGridVisualisation_(), BALL::VIEW::Renderer::renderLine_(), BALL::VIEW::Renderer::renderMesh_(), BALL::VIEW::Renderer::renderMultiLine_(), BALL::VIEW::Renderer::renderPoint_(), BALL::VIEW::Renderer::renderQuadMesh_(), BALL::VIEW::Renderer::renderSimpleBox_(), BALL::VIEW::Renderer::renderSphere_(), BALL::VIEW::Renderer::renderTube_(), BALL::VIEW::Renderer::renderTwoColoredLine_(), and BALL::VIEW::Renderer::renderTwoColoredTube_().
list<int> BALL::LogStream::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.
If a criterion is left empty, it is not used.
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 |
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.
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.
index | the index of the message |
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.
index | the index of the line |
Time BALL::LogStream::getLineTime | ( | const Index & | index | ) | const |
Return the log time of a specific line.
index | the index of the messages |
Size BALL::LogStream::getNumberOfLines | ( | int | min_level =
LogStreamBuf::MIN_LEVEL , |
|
int | max_level =
LogStreamBuf::MAX_LEVEL |
|||
) | const |
Return the number of lines.
This method retruns the number of lines in the buffer for a given range of levels.
min_level | the minimum log level for the counted messages | |
max_level | the maximum log level for the counted messages |
LogStream& BALL::LogStream::info | ( | int | n = 0 |
) |
Log an information message.
This method is equivalent to level (LogStream::INFORMATION + n).
n | the channel |
void BALL::LogStream::insert | ( | std::ostream & | s, | |
int | min_level =
LogStreamBuf::MIN_LEVEL , |
|||
int | max_level =
LogStreamBuf::MAX_LEVEL |
|||
) |
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.
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 |
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.
log << "log message 1"
<< endl;
log.level(4) << "log message 2" <<
endl;
log << "log message 3" <<
endl;
level | the temporary log level |
LogStreamBuf* BALL::LogStream::rdbuf | ( | ) |
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.
s | the stream to be removed |
void BALL::LogStream::setLevel | ( | int | 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.
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.
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.