COOLFluiD
Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
|
Manages a log stream. More...
#include <LogStream.hpp>
Public Types | |
enum | LogTag { ENDLINE } |
Special message tag. More... | |
enum | LogDestination { SCREEN = 1, FILE = 2, STRING = 4, SYNC_SCREEN = 8 } |
Message destination. More... | |
Public Member Functions | |
LogStream (const std::string &streamName, LogLevel level=INFO) | |
Constructor. More... | |
~LogStream () | |
Destructor. More... | |
void | flush () |
Flushes the stream contents. More... | |
LogStream & | operator<< (LogLevel level) |
Overrides operator << for LogLevel type. More... | |
LogStream & | operator<< (LogTag tag) |
Overrides operator << for #Logtag type. More... | |
LogStream & | operator<< (const CodeLocation &codeLoction) |
Overrides operator << for LogLevel type. More... | |
template<typename T > | |
LogStream & | operator<< (const T &t) |
Overrides operator << for any type. More... | |
void | set_log_level (const Uint level) |
Sets new default level. More... | |
void | set_log_level (LogDestination destination, const Uint level) |
Sets new default level to the specified destination. More... | |
void | set_filter (LogLevel level) |
Sets new default level. More... | |
void | set_filter (LogDestination destination, LogLevel level) |
Sets new default level to the specified destination. More... | |
LogLevel | get_filter (LogDestination destination) const |
Gives the default log level of a specified destination. More... | |
void | useDestination (LogDestination destination, bool use) |
Modifies the use policy of a destination. More... | |
bool | isDestinationUsed (LogDestination destination) const |
Gives the use policy of a destination. More... | |
void | setStamp (LogDestination destination, const std::string &stampFormat) |
Sets a stamp format to a specified destination. More... | |
std::string | getStamp (LogDestination destination) |
Gives the stamp format of a specified destination. More... | |
void | setStamp (const std::string &stampFormat) |
Sets a stamp format to all destinations. More... | |
void | setFilterRankZero (LogDestination dest, bool filterRankZero) |
Enables or disables the filter on MPI rank zero on a destination. More... | |
void | setFilterRankZero (bool filterRankZero) |
Enables or disables the filter on MPI rank zero on all destinations. More... | |
bool | getFilterRankZero (LogDestination dest) const |
Checks whether the filter for rank 0 is set on the specified destination. More... | |
void | setFile (const boost::iostreams::file_descriptor_sink &fileDescr) |
Sets the file. More... | |
bool | isFileOpen () const |
Cheks whether the file is set. More... | |
void | addStringForwarder (LogStringForwarder *forwarder) |
Appends a string forwarder to the forwarder list. More... | |
void | removeStringForwarder (LogStringForwarder *forwarder) |
Removes a string from the forwarder list. More... | |
unsigned int | getStringForwarderCount () const |
Gives the number of string forwarders the stream contains. More... | |
Private Member Functions | |
LogLevelFilter & | getLevelFilter (LogDestination dest) const |
Gives the level filter of a destination. More... | |
LogStampFilter & | getStampFilter (LogDestination dest) const |
Gives the stamp filter of a destination. More... | |
Private Attributes | |
std::map< LogDestination, boost::iostreams::filtering_ostream * > | m_destinations |
Destinations. More... | |
std::list< LogStringForwarder * > | m_stringForwarders |
The forwarder list. More... | |
std::map< LogDestination, bool > | m_usedDests |
Use policies. More... | |
std::map< LogDestination, bool > | m_filterRankZero |
Rank zero filter. More... | |
std::string | m_buffer |
Buffer for STRING destination. More... | |
std::string | m_streamName |
Stream name. More... | |
LogLevel | m_filter_level |
Default value. More... | |
bool | m_flushed |
Flush status. More... | |
Manages a log stream.
Definition at line 30 of file LogStream.hpp.
enum LogDestination |
Message destination.
Definition at line 47 of file LogStream.hpp.
enum LogTag |
Special message tag.
For now, the only available tag is ENDLINE
.
Enumerator | |
---|---|
ENDLINE |
Indicates the end of a message. This tag must be used to flush stream buffers and must end each log message to guarantee that the stream buffers are flushed. |
Definition at line 37 of file LogStream.hpp.
~LogStream | ( | ) |
Destructor.
Frees all allocated memory. The file stream is not destroyed. All unflushed streams are flushed
Definition at line 73 of file LogStream.cpp.
void addStringForwarder | ( | LogStringForwarder * | forwarder | ) |
Appends a string forwarder to the forwarder list.
The forwarder is linked to the string buffer and its message()
method is called. If the pointer is NULL
or already exists in the forwarder list, nothing is done.
forwarder | The forwarder to append. |
Definition at line 351 of file LogStream.cpp.
void flush | ( | ) |
Flushes the stream contents.
Definition at line 130 of file LogStream.cpp.
LogLevel get_filter | ( | LogDestination | destination | ) | const |
Gives the default log level of a specified destination.
destination | The destination. |
Definition at line 222 of file LogStream.cpp.
bool getFilterRankZero | ( | LogDestination | dest | ) | const |
Checks whether the filter for rank 0 is set on the specified destination.
dest | The destination to check |
true
if the filter is set; otherwise, returns false
. Definition at line 291 of file LogStream.cpp.
|
private |
Gives the level filter of a destination.
dest | The destination |
Definition at line 327 of file LogStream.cpp.
std::string getStamp | ( | LogDestination | destination | ) |
Gives the stamp format of a specified destination.
destination | The destination |
Definition at line 257 of file LogStream.cpp.
|
private |
Gives the stamp filter of a destination.
dest | The destination |
Definition at line 335 of file LogStream.cpp.
unsigned int getStringForwarderCount | ( | ) | const |
Gives the number of string forwarders the stream contains.
Definition at line 371 of file LogStream.cpp.
bool isDestinationUsed | ( | LogDestination | destination | ) | const |
Gives the use policy of a destination.
If destination
is FILE
but isFileOpen()
returns false
, this method returns false
.
Definition at line 238 of file LogStream.cpp.
bool isFileOpen | ( | ) | const |
Cheks whether the file is set.
true
if the file has already been set. Definition at line 343 of file LogStream.cpp.
Overrides operator << for LogLevel
type.
Sets #level
as current level for all destinations.
level | The level. |
Definition at line 87 of file LogStream.cpp.
Overrides operator << for #Logtag
type.
If tag
is ENDLINE
, all stream buffers are flushed.
tag | The tag |
Definition at line 103 of file LogStream.cpp.
LogStream & operator<< | ( | const CodeLocation & | codeLoction | ) |
Overrides operator << for LogLevel
type.
Sets #codeLoction
as current code location for all destinations.
Definition at line 114 of file LogStream.cpp.
|
inline |
Overrides operator << for any type.
Appends t
to the stream
t | The value to append |
Definition at line 104 of file LogStream.hpp.
void removeStringForwarder | ( | LogStringForwarder * | forwarder | ) |
Removes a string from the forwarder list.
If the pointer is NULL
or does not exist in the forwarder list, nothing is done.
forwarder | The forwarder to remove. |
Definition at line 363 of file LogStream.cpp.
void set_filter | ( | LogLevel | level | ) |
Sets new default level.
level
is set as default log level to all destinations.
level | The new default level. |
Definition at line 199 of file LogStream.cpp.
void set_filter | ( | LogDestination | destination, |
LogLevel | level | ||
) |
Sets new default level to the specified destination.
If destination
is FILE
but isFileOpen()
returns false
, nothing is done.
destination | The destination. |
level | The new default level. |
Definition at line 214 of file LogStream.cpp.
void set_log_level | ( | const Uint | level | ) |
Sets new default level.
level
is set as default log level to all destinations.
level | The new default level. |
Definition at line 177 of file LogStream.cpp.
void set_log_level | ( | LogDestination | destination, |
const Uint | level | ||
) |
Sets new default level to the specified destination.
If destination
is FILE
but isFileOpen()
returns false
, nothing is done.
destination | The destination. |
level | The new default level. |
Definition at line 191 of file LogStream.cpp.
void setFile | ( | const boost::iostreams::file_descriptor_sink & | fileDescr | ) |
Sets the file.
Once this method has been called:
FILE
destination becomes available and isFileOpen()
returns true
. fileDescr | The file descriptor. |
Definition at line 310 of file LogStream.cpp.
void setFilterRankZero | ( | LogDestination | dest, |
bool | filterRankZero | ||
) |
Enables or disables the filter on MPI rank zero on a destination.
If enabled, only messages coming from process with MPI rank zero are forwarded to that destination.
dest | The destination |
filterRankZero | If true , the filter is set to "enabled"; otherwise, it is set to "disabled". |
Definition at line 283 of file LogStream.cpp.
void setFilterRankZero | ( | bool | filterRankZero | ) |
Enables or disables the filter on MPI rank zero on all destinations.
If enabled, only messages coming from process with MPI rank zero are forwarded to that destination.
filterRankZero | If true , the filter is set to "enabled"; otherwise, it is set to "disabled". |
Definition at line 299 of file LogStream.cpp.
void setStamp | ( | LogDestination | destination, |
const std::string & | stampFormat | ||
) |
Sets a stamp format to a specified destination.
If destination
is FILE
but isFileOpen()
returns false
, nothing is done.
destination | The destination |
stampFormat | The stamp format |
Definition at line 249 of file LogStream.cpp.
void setStamp | ( | const std::string & | stampFormat | ) |
Sets a stamp format to all destinations.
stampFormat | The stamp format |
Definition at line 269 of file LogStream.cpp.
void useDestination | ( | LogDestination | destination, |
bool | use | ||
) |
Modifies the use policy of a destination.
If destination
is FILE
but isFileOpen()
returns false
, nothing is done.
destination | The destination. |
use | If true , the destination is set to "use"; otherwise it is set to "not use". |
Definition at line 230 of file LogStream.cpp.
|
private |
Buffer for STRING
destination.
Definition at line 303 of file LogStream.hpp.
|
private |
Destinations.
The key is the destination. The value is the corresponding stream.
Definition at line 287 of file LogStream.hpp.
|
private |
Default value.
This attribute is used on FILE
stream creation. Its value is modified by #setLogLevel(LogLevel)
.
Definition at line 314 of file LogStream.hpp.
|
private |
Rank zero filter.
The key is the destination. The value is the corresponding filter policy.
Definition at line 300 of file LogStream.hpp.
|
private |
Flush status.
If true
, the streams are flushed. This attribute is used in object destrutor. If at this moment, it is false
, the streams are flushed before their destruction.
Definition at line 321 of file LogStream.hpp.
|
private |
Stream name.
This attribute is used on FILE
stream creation.
Definition at line 308 of file LogStream.hpp.
|
private |
The forwarder list.
Definition at line 290 of file LogStream.hpp.
|
private |
Use policies.
The key is the destination. The value is the corresponding use policy.
Definition at line 295 of file LogStream.hpp.
Send comments to: COOLFluiD Web Admin |