Abstract base class defining the interface of all LogStreams.
More...
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/main/src/axom/slic/core/LogStream.hpp>
|
| | LogStream () |
| |
| virtual | ~LogStream () |
| |
| void | setFormatString (const std::string &format) |
| | Sets the format string. More...
|
| |
| virtual void | append (message::Level msgLevel, const std::string &message, const std::string &tagName, const std::string &fileName, int line, bool filter_duplicates, bool tag_stream_only)=0 |
| | Appends the given message to the stream. More...
|
| |
| virtual void | outputLocal () |
| | Outputs the log stream on the current rank to the console. It's a NO-OP by default. More...
|
| |
| virtual void | flush () |
| | Flushes the log stream on all ranks. It's a NO-OP by default. More...
|
| |
| virtual void | push () |
| | Pushes messages incrementally up the log stream. NO-OP by default. More...
|
| |
| virtual bool | hasPendingMessages () |
| | Tests whether there are any pending messages that need to be flushed. This method should only be overriden for LogStream inherited classes that can reliably test whether pending messages exist. More...
|
| |
| virtual bool | isUsingMPI () |
| | Tests whether this class relies on MPI. More...
|
| |
|
| std::string | getFormatedMessage (const std::string &msgLevel, const std::string &message, const std::string &tagName, const std::string &rank, const std::string &rank_count, const std::string &fileName, int line) |
| | Get the communicator. More...
|
| |
| std::string | getTimeStamp () |
| | Returns a time-stamp. More...
|
| |
Abstract base class defining the interface of all LogStreams.
Concrete instances implement the append() method accordingly, e.g., to append the message to a file, write it to stdout, etc.
- See also
- Logger Console
◆ LogStream()
| axom::slic::LogStream::LogStream |
( |
| ) |
|
◆ ~LogStream()
| virtual axom::slic::LogStream::~LogStream |
( |
| ) |
|
|
virtual |
◆ setFormatString()
| void axom::slic::LogStream::setFormatString |
( |
const std::string & |
format | ) |
|
|
inline |
Sets the format string.
- Parameters
-
- Note
- The following keywords in the format string are replaced:
-
<LEVEL> with the message type, e.g, ERROR, FATAL, etc.
-
<MESSAGE> with the user-supplied message
-
<TAG> user-supplied tag
-
<FILE> with the filename
-
<LINE> with the line number
-
<RANK> with the MPI rank(s)
-
<RANK_COUNT> with the number of MPI ranks
-
<TIMESTAMP> date/time the message is logged
An example illustrating how an application can setup the format string is shown below:
std::string format =
std::string( "***********************************\n" )+
std::string( "* <TIMESTAMP>\n\n" ) +
std::string( "* LEVEL=<LEVEL>\n" ) +
std::string( "* MESSAGE=<MESSAGE>\n" ) +
std::string( "* FILE=<FILE>\n" ) +
std::string( "* LINE=<LINE>\n" ) +
std::string( "* RANK=<RANK>\n" ) +
std::string( "* RANK_COUNT=<RANK_COUNT>\n" ) +
std::string( "***********************************\n" );
◆ append()
| virtual void axom::slic::LogStream::append |
( |
message::Level |
msgLevel, |
|
|
const std::string & |
message, |
|
|
const std::string & |
tagName, |
|
|
const std::string & |
fileName, |
|
|
int |
line, |
|
|
bool |
filter_duplicates, |
|
|
bool |
tag_stream_only |
|
) |
| |
|
pure virtual |
Appends the given message to the stream.
- Parameters
-
| [in] | msgLevel | the level of the message. |
| [in] | message | the user-supplied message. |
| [in] | tagName | user-supplied tag to associate with the given message. |
| [in] | fileName | the file where this message is appended |
| [in] | line | the line within the file at which the message is appended. |
| [in] | filter_duplicates | optional parameter that indicates whether duplicate messages resulting from running in parallel will be filtered out. /param [in] tag_stream_only optional parameter that indicates whether the message will go only to streams bound to tagName. |
- Note
- The following wildcards may be used to ignore a particular field:
-
MSG_IGNORE_TAG
-
MSG_IGNORE_FILE
-
MSG_IGNORE_LINE
Implemented in axom::slic::SynchronizedStream, axom::slic::LumberjackStream, and axom::slic::GenericOutputStream.
◆ outputLocal()
| virtual void axom::slic::LogStream::outputLocal |
( |
| ) |
|
|
inlinevirtual |
Outputs the log stream on the current rank to the console. It's a NO-OP by default.
- Note
- The intent of this method is to be overridden by concrete implementations. This is primarily useful for applications running in a distributed MPI environment. This function is not intended to be collective. The function outputs messages stored by the stream directly to the console, skipping the intermediate synchronization checkpoint that a flush() performs.
- Warning
- This method is being called before slic aborts.
Reimplemented in axom::slic::SynchronizedStream, axom::slic::LumberjackStream, and axom::slic::GenericOutputStream.
◆ flush()
| virtual void axom::slic::LogStream::flush |
( |
| ) |
|
|
inlinevirtual |
◆ push()
| virtual void axom::slic::LogStream::push |
( |
| ) |
|
|
inlinevirtual |
Pushes messages incrementally up the log stream. NO-OP by default.
- Note
- The intent of this method is to be overridden by concrete implementations that need to be incrementally advanced. This is primarily useful for applications running in a distributed MPI environment, where the push is a collective operation intended for a incrementally advancing messages through the log stream.
Reimplemented in axom::slic::LumberjackStream.
◆ hasPendingMessages()
| virtual bool axom::slic::LogStream::hasPendingMessages |
( |
| ) |
|
|
inlinevirtual |
◆ isUsingMPI()
| virtual bool axom::slic::LogStream::isUsingMPI |
( |
| ) |
|
|
inlinevirtual |
◆ getFormatedMessage()
| std::string axom::slic::LogStream::getFormatedMessage |
( |
const std::string & |
msgLevel, |
|
|
const std::string & |
message, |
|
|
const std::string & |
tagName, |
|
|
const std::string & |
rank, |
|
|
const std::string & |
rank_count, |
|
|
const std::string & |
fileName, |
|
|
int |
line |
|
) |
| |
|
protected |
Get the communicator.
- Returns
- Returns the communicator if it exists, or MPI_COMM_NULL otherwise
Returns the formatted message as a single string.
- Parameters
-
| [in] | msgLevel | the level of the given message. |
| [in] | message | the user-supplied message. |
| [in] | tagName | user-supplied tag, may be MSG_IGNORE_TAG |
| [in] | fileName | filename where this message is logged, may be MSG_IGNORE_FILE to ignore this field. |
| [in] | rank | The MPI rank(s) that emitted this message |
| [in] | rank_count | the number of MPI ranks that emitted this message |
| [in] | line | the line number within the file where the message is logged. Likewise, may be set to MSG_IGNORE_LINE to ignore this field. |
- Returns
- str the formatted message string.
- Postcondition
- str != "".
◆ getTimeStamp()
| std::string axom::slic::LogStream::getTimeStamp |
( |
| ) |
|
|
protected |
Returns a time-stamp.
- Returns
- str a textual representation of the current time.
The documentation for this class was generated from the following file:
- /home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/main/src/axom/slic/core/LogStream.hpp