AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::slic::LogStream Class Referenceabstract

Abstract base class defining the interface of all LogStreams. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/develop/src/axom/slic/core/LogStream.hpp>

Inheritance diagram for axom::slic::LogStream:

Public Member Functions

 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...
 

Protected Member Functions

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...
 

Detailed Description

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

Constructor & Destructor Documentation

◆ LogStream()

axom::slic::LogStream::LogStream ( )

◆ ~LogStream()

virtual axom::slic::LogStream::~LogStream ( )
virtual

Member Function Documentation

◆ setFormatString()

void axom::slic::LogStream::setFormatString ( const std::string &  format)
inline

Sets the format string.

Parameters
formata format string
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]msgLevelthe level of the message.
[in]messagethe user-supplied message.
[in]tagNameuser-supplied tag to associate with the given message.
[in]fileNamethe file where this message is appended
[in]linethe line within the file at which the message is appended.
[in]filter_duplicatesoptional 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

Flushes the log stream on all ranks. 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, where the flush is a collective operation intended for a synchronization checkpoint.

Reimplemented in axom::slic::SynchronizedStream, axom::slic::LumberjackStream, and axom::slic::GenericOutputStream.

◆ 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

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.

Returns
Returns true if there are pending messages that need to be flushed

Reimplemented in axom::slic::SynchronizedStream, and axom::slic::LumberjackStream.

◆ isUsingMPI()

virtual bool axom::slic::LogStream::isUsingMPI ( )
inlinevirtual

Tests whether this class relies on MPI.

Returns
Returns true if this class relies on MPI

Reimplemented in axom::slic::SynchronizedStream, and axom::slic::LumberjackStream.

◆ 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]msgLevelthe level of the given message.
[in]messagethe user-supplied message.
[in]tagNameuser-supplied tag, may be MSG_IGNORE_TAG
[in]fileNamefilename where this message is logged, may be MSG_IGNORE_FILE to ignore this field.
[in]rankThe MPI rank(s) that emitted this message
[in]rank_countthe number of MPI ranks that emitted this message
[in]linethe 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: