Public Types | Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
messageStream Class Reference

Handle output messages in a simple, consistent stream-based manner. More...

Inheritance diagram for messageStream:
Inheritance graph
[legend]
Collaboration diagram for messageStream:
Collaboration graph
[legend]

Public Types

enum  errorSeverity {
  INFO = 1, INFO_STDERR, WARNING, SERIOUS,
  FATAL
}
 

Public Member Functions

 messageStream (const string &title, const errorSeverity severity, const int maxErrors=0)
 
 messageStream (const dictionary &dict)
 
const stringtitle () const noexcept
 
int maxErrors () const noexcept
 
int maxErrors (int nErrors) noexcept
 
OSstreamstream (OSstream *alternative=nullptr)
 
OSstreammasterStream (const label communicator)
 
std::ostream & stdStream ()
 
 operator OSstream & ()
 
OSstreamoperator() ()
 
OSstreamoperator() (const string &functionName)
 
OSstreamoperator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber=0)
 
OSstreamoperator() (const string &functionName, const char *sourceFileName, const int sourceFileLineNumber=0)
 
OSstreamoperator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const string &ioFileName, const label ioStartLineNumber=-1, const label ioEndLineNumber=-1)
 
OSstreamoperator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const IOstream &)
 
OSstreamoperator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const dictionary &)
 

Static Public Attributes

static int level
 
static int redirect
 

Protected Attributes

string title_
 
errorSeverity severity_
 
int maxErrors_
 
int errorCount_
 

Detailed Description

Handle output messages in a simple, consistent stream-based manner.

The messageStream class is globally instantiated with a title string and a severity (which controls the program termination), optionally with a max number of errors before termination.

Errors, messages and other data are sent to the messageStream class in the standard manner.

For parallel applications, the output for 'standard' messages (Info, Warnings) is effectively suppressed on all sub-processes, which results in a single output message instead of a flood of output messages from each process. The error type of messages do, however, retain output on all processes, which ensures that parallel termination occurs correctly and the source of the problem is properly traceable to the originating processor.

Source files

Definition at line 69 of file messageStream.H.

Member Enumeration Documentation

◆ errorSeverity

Enumerator
INFO 

General information output (stdout)

INFO_STDERR 

General information output (stderr)

WARNING 

Warning of possible problem.

SERIOUS 

A serious problem - eg, data corruption.

FATAL 

A fatal error.

Definition at line 74 of file messageStream.H.

Constructor & Destructor Documentation

◆ messageStream() [1/2]

messageStream ( const string title,
const errorSeverity  severity,
const int  maxErrors = 0 
)

Definition at line 40 of file messageStream.C.

◆ messageStream() [2/2]

messageStream ( const dictionary dict)
explicit

Definition at line 53 of file messageStream.C.

Member Function Documentation

◆ title()

const string& title ( ) const
inlinenoexcept

Definition at line 133 of file messageStream.H.

References messageStream::title_.

◆ maxErrors() [1/2]

int maxErrors ( ) const
inlinenoexcept

Definition at line 139 of file messageStream.H.

References messageStream::maxErrors_.

◆ maxErrors() [2/2]

int maxErrors ( int  nErrors)
inlinenoexcept

Definition at line 146 of file messageStream.H.

References messageStream::maxErrors_.

◆ stream()

Foam::OSstream & stream ( OSstream alternative = nullptr)

◆ masterStream()

Foam::OSstream & masterStream ( const label  communicator)

◆ stdStream()

std::ostream & stdStream ( )

Definition at line 150 of file messageStream.C.

Referenced by argList::argList(), argList::parse(), and argList::printUsage().

Here is the caller graph for this function:

◆ operator OSstream &()

operator OSstream & ( )
inline

Definition at line 169 of file messageStream.H.

References messageStream::stream().

Here is the call graph for this function:

◆ operator()() [1/7]

OSstream& operator() ( )
inline

Definition at line 175 of file messageStream.H.

References messageStream::stream().

Here is the call graph for this function:

◆ operator()() [2/7]

Foam::OSstream & operator() ( const string functionName)

Definition at line 159 of file messageStream.C.

References Foam::nl, and os().

Here is the call graph for this function:

◆ operator()() [3/7]

Foam::OSstream & operator() ( const char *  functionName,
const char *  sourceFileName,
const int  sourceFileLineNumber = 0 
)

Definition at line 176 of file messageStream.C.

References Foam::endl(), Foam::nl, and os().

Here is the call graph for this function:

◆ operator()() [4/7]

Foam::OSstream & operator() ( const string functionName,
const char *  sourceFileName,
const int  sourceFileLineNumber = 0 
)

Definition at line 195 of file messageStream.C.

◆ operator()() [5/7]

Foam::OSstream & operator() ( const char *  functionName,
const char *  sourceFileName,
const int  sourceFileLineNumber,
const string ioFileName,
const label  ioStartLineNumber = -1,
const label  ioEndLineNumber = -1 
)

Definition at line 211 of file messageStream.C.

References Foam::endl(), Foam::nl, and os().

Here is the call graph for this function:

◆ operator()() [6/7]

Foam::OSstream & operator() ( const char *  functionName,
const char *  sourceFileName,
const int  sourceFileLineNumber,
const IOstream ioStream 
)
Parameters
ioStreamProvides name and lineNumber

Definition at line 245 of file messageStream.C.

◆ operator()() [7/7]

Foam::OSstream & operator() ( const char *  functionName,
const char *  sourceFileName,
const int  sourceFileLineNumber,
const dictionary dict 
)
Parameters
dictProvides name, startLine, endLine

Definition at line 265 of file messageStream.C.

References dict, dictionary::endLineNumber(), dictionary::relativeName(), and dictionary::startLineNumber().

Here is the call graph for this function:

Member Data Documentation

◆ title_

string title_
protected

Definition at line 91 of file messageStream.H.

Referenced by messageStream::title().

◆ severity_

errorSeverity severity_
protected

Definition at line 92 of file messageStream.H.

◆ maxErrors_

int maxErrors_
protected

Definition at line 93 of file messageStream.H.

Referenced by messageStream::maxErrors().

◆ errorCount_

int errorCount_
protected

Definition at line 94 of file messageStream.H.

◆ level

int level
static

Definition at line 108 of file messageStream.H.

Referenced by IOobject::setBad(), error::write(), and IOerror::write().

◆ redirect

int redirect
static

Definition at line 113 of file messageStream.H.


The documentation for this class was generated from the following files: