messageStream Class Reference

Class to handle messaging in a simple, consistent stream-based manner. More...

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

Public Types

enum  errorSeverity {
  INFO = 1, WARNING, SERIOUS, FATAL,
  INFO_STDERR = INFO | 0x10
}
 Message type, or error severity flags. More...
 

Public Member Functions

 messageStream (const string &title, const errorSeverity severity, const int maxErrors=0)
 Construct from components. More...
 
 messageStream (const dictionary &dict)
 Construct as Fatal from dictionary, extracting the 'title'. More...
 
const string & title () const
 The title of this error type. More...
 
int maxErrors () const
 The maximum number of errors before program termination. More...
 
int & maxErrors ()
 
OSstream & masterStream (const label communicator)
 Convert to OSstream. More...
 
OSstream & operator() (const string &functionName)
 Print basic message. More...
 
OSstream & operator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber=0)
 Print basic message. More...
 
OSstream & operator() (const string &functionName, const char *sourceFileName, const int sourceFileLineNumber=0)
 Print basic message. More...
 
OSstream & operator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const string &ioFileName, const label ioStartLineNumber=-1, const label ioEndLineNumber=-1)
 Print basic message. More...
 
OSstream & operator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const IOstream &)
 Print basic message. More...
 
OSstream & operator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const dictionary &)
 Print basic message. More...
 
 operator OSstream & ()
 Convert to OSstream for << operations. More...
 
OSstream & operator() ()
 Explicitly convert to OSstream for << operations. More...
 

Static Public Attributes

static int level
 Control the output verbosity of messageStream. More...
 

Protected Attributes

string title_
 
errorSeverity severity_
 
int maxErrors_
 
int errorCount_
 

Detailed Description

Class to handle messaging 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) and a number of errors before termination. Errors, messages and other data are sent to the messageStream class in the standard manner.

Usage
<< "message1" << "message2" << FoamDataType << endl;
Source files

Definition at line 71 of file messageStream.H.

Member Enumeration Documentation

◆ errorSeverity

Message type, or error severity flags.

Enumerator
INFO 

General information output.

WARNING 

Warning of possible problem.

SERIOUS 

A serious problem - eg, data corruption.

FATAL 

A fatal error.

INFO_STDERR 

Information, but on stderr.

Definition at line 76 of file messageStream.H.

Constructor & Destructor Documentation

◆ messageStream() [1/2]

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

Construct from components.

Definition at line 45 of file messageStream.C.

◆ messageStream() [2/2]

messageStream ( const dictionary &  dict)
explicit

Construct as Fatal from dictionary, extracting the 'title'.

Definition at line 58 of file messageStream.C.

Member Function Documentation

◆ title()

const string& title ( ) const
inline

The title of this error type.

Definition at line 127 of file messageStream.H.

References messageStream::title_.

Referenced by pointNoise::processData().

Here is the caller graph for this function:

◆ maxErrors() [1/2]

int maxErrors ( ) const
inline

The maximum number of errors before program termination.

Definition at line 133 of file messageStream.H.

References messageStream::maxErrors_.

◆ maxErrors() [2/2]

int& maxErrors ( )
inline

Non-const access to the maximum number of errors before program termination to enable user to reset it

Definition at line 140 of file messageStream.H.

References messageStream::maxErrors_.

◆ masterStream()

Foam::OSstream & masterStream ( const label  communicator)

Convert to OSstream.

Prints to Pout for the master stream

Definition at line 69 of file messageStream.C.

References Foam::endl(), UPstream::master(), Foam::Pout, error::printStack(), Foam::Snull, UPstream::warnComm, and UPstream::worldComm.

Referenced by smoothSolver::solve(), fvMatrix< Type >::fvSolver::solve(), GAMGSolver::solve(), fvMatrix< Type >::solveCoupled(), fvMatrix< Type >::solver(), fvMatrix< Type >::solveSegregated(), and fvMatrix< Type >::solveSegregatedOrCoupled().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator()() [1/7]

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

Print basic message.

Returns
OSstream for further info.

Definition at line 89 of file messageStream.C.

References Foam::nl.

◆ operator()() [2/7]

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

Print basic message.

Returns
OSstream for further info.

Definition at line 103 of file messageStream.C.

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

Here is the call graph for this function:

◆ operator()() [3/7]

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

Print basic message.

Returns
OSstream for further info.

Definition at line 122 of file messageStream.C.

◆ operator()() [4/7]

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

Print basic message.

Returns
OSstream for further info.

Definition at line 138 of file messageStream.C.

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

Here is the call graph for this function:

◆ operator()() [5/7]

Foam::OSstream & operator() ( const char *  functionName,
const char *  sourceFileName,
const int  sourceFileLineNumber,
const IOstream &  ioStream 
)

Print basic message.

Returns
OSstream for further info.

Definition at line 172 of file messageStream.C.

◆ operator()() [6/7]

Foam::OSstream & operator() ( const char *  functionName,
const char *  sourceFileName,
const int  sourceFileLineNumber,
const dictionary &  dict 
)

Print basic message.

Returns
OSstream for further info.

Definition at line 192 of file messageStream.C.

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

Here is the call graph for this function:

◆ operator OSstream &()

operator OSstream & ( )

Convert to OSstream for << operations.

◆ operator()() [7/7]

OSstream& operator() ( )
inline

Explicitly convert to OSstream for << operations.

Definition at line 210 of file messageStream.H.

Member Data Documentation

◆ title_

string title_
protected

Definition at line 90 of file messageStream.H.

Referenced by messageStream::title().

◆ severity_

errorSeverity severity_
protected

Definition at line 91 of file messageStream.H.

◆ maxErrors_

int maxErrors_
protected

Definition at line 92 of file messageStream.H.

Referenced by messageStream::maxErrors().

◆ errorCount_

int errorCount_
protected

Definition at line 93 of file messageStream.H.

◆ level

int level
static

Control the output verbosity of messageStream.

  • level == 0 : suppress all output
  • level == 1 : normal output
  • level >= 2 : report source file name and line number if available

    Note
    The default level is normally 2.

Definition at line 107 of file messageStream.H.

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


The documentation for this class was generated from the following files:
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::messageStream::messageStream
messageStream(const string &title, const errorSeverity severity, const int maxErrors=0)
Construct from components.
Definition: messageStream.C:45