Handle output messages in a simple, consistent stream-based manner. More...
#include <messageStream.H>


Public Types | |
| enum | errorSeverity : int { INFO = 1 , WARNING , SERIOUS , FATAL , USE_STDERR = 0x80 } |
| Message type, error severity flags. More... | |
Public Member Functions | |
| messageStream (errorSeverity severity, int maxErrors=0, bool use_stderr=false) | |
| Construct untitled with given characteristics. | |
| messageStream (const char *title, errorSeverity severity, int maxErrors=0, bool use_stderr=false) | |
| Construct from components. | |
| messageStream (string title, errorSeverity severity, int maxErrors=0, bool use_stderr=false) | |
| Construct from components. | |
| messageStream (const dictionary &dict) | |
| Construct from dictionary as Fatal, extracting 'title'. | |
| const string & | title () const noexcept |
| The title of this error type. | |
| int | maxErrors () const noexcept |
| The maximum number of errors before program termination. | |
| int | maxErrors (int nErrors) noexcept |
| Set the maximum number of errors before program termination. | |
| OSstream & | stream (OSstream *alternative=nullptr, int communicator=-1) |
| Return OSstream for output operations. | |
| OSstream & | masterStream (int communicator) |
| Return OSstream for output operations on the master process only, Snull on other processes. | |
| std::ostream & | stdStream () |
| Return std::ostream for output operations. | |
| OSstream & | deprecated (const int afterVersion, const char *functionName=nullptr, const char *sourceFileName=nullptr, const int sourceFileLineNumber=0) |
| Report deprecation (after specified API version) with 'From function-name, source file, line number'. | |
| operator OSstream & () | |
| Implicit cast to OSstream for << operations. | |
| OSstream & | operator() () |
| Explicitly convert to OSstream for << operations. | |
| OSstream & | operator() (const std::string &functionName, const char *sourceFileName=nullptr, const int sourceFileLineNumber=0) |
| Report 'From function-name', optionally with 'source file, line number'. | |
| OSstream & | operator() (const char *functionName, const char *sourceFileName=nullptr, const int sourceFileLineNumber=0) |
| Report 'From function-name', optionally with 'source file, line number'. | |
| OSstream & | operator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const std::string &ioFileName, const label ioStartLineNumber=-1, const label ioEndLineNumber=-1) |
| Report 'From function-name, source file, line number' as well as io-file name and location. | |
| OSstream & | operator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const IOstream &) |
| Report 'From function-name, source file, line number' as well as io-file name and location. | |
| OSstream & | operator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber, const dictionary &) |
| Report 'From function-name, source file, line number' as well as io-file name and location. | |
Static Public Attributes | |
| static int | level |
| The output level (verbosity) of messages. | |
| static int | redirect |
| The output redirection of messages. | |
Protected Attributes | |
| string | title_ |
| The title of this error type. | |
| int | severity_ |
| The message type / error severity, possibly with USE_STDERR mask. | |
| int | maxErrors_ |
| The maximum number of errors before program termination. | |
| int | errorCount_ |
| The current number of errors counted. | |
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.
Definition at line 72 of file messageStream.H.
| enum errorSeverity : int |
Message type, error severity flags.
Definition at line 79 of file messageStream.H.
|
explicit |
Construct untitled with given characteristics.
Definition at line 43 of file messageStream.C.
References errorCount_, maxErrors(), maxErrors_, severity_, and USE_STDERR.
Referenced by error::error(), error::error(), error::error(), messageStream(), messageStream(), and messageStream().


| messageStream | ( | const char * | title, |
| errorSeverity | severity, | ||
| int | maxErrors = 0, | ||
| bool | use_stderr = false ) |
Construct from components.
Definition at line 61 of file messageStream.C.
References maxErrors(), messageStream(), title(), and title_.

| messageStream | ( | string | title, |
| errorSeverity | severity, | ||
| int | maxErrors = 0, | ||
| bool | use_stderr = false ) |
Construct from components.
Definition at line 78 of file messageStream.C.
References maxErrors(), messageStream(), title(), and title_.

|
explicit |
Construct from dictionary as Fatal, extracting 'title'.
Definition at line 92 of file messageStream.C.
References dict, FATAL, and messageStream().

|
inlinenoexcept |
The title of this error type.
Definition at line 190 of file messageStream.H.
References Foam::noexcept, and title_.
Referenced by error::error(), error::error(), IOerror::IOerror(), IOerror::IOerror(), messageStream(), messageStream(), error::write(), and IOerror::write().

|
inlinenoexcept |
The maximum number of errors before program termination.
Definition at line 198 of file messageStream.H.
References maxErrors_, and Foam::noexcept.
Referenced by messageStream(), messageStream(), and messageStream().

|
inlinenoexcept |
Set the maximum number of errors before program termination.
Definition at line 208 of file messageStream.H.
References maxErrors_.
| Foam::OSstream & stream | ( | OSstream * | alternative = nullptr, |
| int | communicator = -1 ) |
Return OSstream for output operations.
| alternative | An alternative output stream (serial-only) |
| communicator | Communicator. Negative is treated like UPstream::worldComm |
Definition at line 100 of file messageStream.C.
References Foam::abort(), errorCount_, Foam::FatalError, FatalErrorInFunction, INFO, Foam::infoDetailLevel, level, UPstream::master(), maxErrors_, UPstream::parRun(), Foam::Perr, Foam::Pout, redirect, Foam::Serr, severity_, Foam::Snull, Foam::Sout, title_, USE_STDERR, WARNING, and UPstream::worldComm.
Referenced by deprecated(), masterStream(), operator OSstream &(), operator()(), operator()(), operator()(), and stdStream().


| Foam::OSstream & masterStream | ( | int | communicator | ) |
Return OSstream for output operations on the master process only, Snull on other processes.
A negative communicator is treated like UPstream::worldComm
Definition at line 181 of file messageStream.C.
References Foam::endl(), UPstream::master(), Foam::Perr, error::printStack(), Foam::Snull, stream(), UPstream::warnComm, and UPstream::worldComm.

| std::ostream & stdStream | ( | ) |
Return std::ostream for output operations.
Definition at line 203 of file messageStream.C.
References stream().

| Foam::OSstream & deprecated | ( | const int | afterVersion, |
| const char * | functionName = nullptr, | ||
| const char * | sourceFileName = nullptr, | ||
| const int | sourceFileLineNumber = 0 ) |
Report deprecation (after specified API version) with 'From function-name, source file, line number'.
Definition at line 212 of file messageStream.C.
References Foam::foamVersion::api, Foam::nl, os(), and stream().

|
inline |
Implicit cast to OSstream for << operations.
Definition at line 260 of file messageStream.H.
References stream().

|
inline |
Explicitly convert to OSstream for << operations.
Definition at line 268 of file messageStream.H.
References stream().

| Foam::OSstream & operator() | ( | const std::string & | functionName, |
| const char * | sourceFileName = nullptr, | ||
| const int | sourceFileLineNumber = 0 ) |
| Foam::OSstream & operator() | ( | const char * | functionName, |
| const char * | sourceFileName = nullptr, | ||
| const int | sourceFileLineNumber = 0 ) |
| Foam::OSstream & operator() | ( | const char * | functionName, |
| const char * | sourceFileName, | ||
| const int | sourceFileLineNumber, | ||
| const std::string & | ioFileName, | ||
| const label | ioStartLineNumber = -1, | ||
| const label | ioEndLineNumber = -1 ) |
Report 'From function-name, source file, line number' as well as io-file name and location.
Definition at line 333 of file messageStream.C.
References Foam::endl(), and os().

| Foam::OSstream & operator() | ( | const char * | functionName, |
| const char * | sourceFileName, | ||
| const int | sourceFileLineNumber, | ||
| const IOstream & | ioStream ) |
Report 'From function-name, source file, line number' as well as io-file name and location.
| ioStream | Provides name and lineNumber |
Definition at line 368 of file messageStream.C.
| Foam::OSstream & operator() | ( | const char * | functionName, |
| const char * | sourceFileName, | ||
| const int | sourceFileLineNumber, | ||
| const dictionary & | dict ) |
Report 'From function-name, source file, line number' as well as io-file name and location.
| dict | Provides name, startLine, endLine |
Definition at line 388 of file messageStream.C.
References dict.
|
protected |
The title of this error type.
Definition at line 101 of file messageStream.H.
Referenced by messageStream(), messageStream(), stream(), and title().
|
protected |
The message type / error severity, possibly with USE_STDERR mask.
Definition at line 106 of file messageStream.H.
Referenced by messageStream(), and stream().
|
protected |
The maximum number of errors before program termination.
Definition at line 111 of file messageStream.H.
Referenced by maxErrors(), maxErrors(), messageStream(), and stream().
|
protected |
The current number of errors counted.
Definition at line 116 of file messageStream.H.
Referenced by messageStream(), and stream().
|
static |
The output level (verbosity) of messages.
Definition at line 133 of file messageStream.H.
Referenced by IOobject::setBad(), stream(), error::write(), and IOerror::write().
|
static |
The output redirection of messages.
Definition at line 141 of file messageStream.H.
Referenced by stream().