Handle output messages in a simple, consistent stream-based manner. More...
Public Types | |
enum | errorSeverity { INFO = 1, INFO_STDERR, WARNING, SERIOUS, FATAL } |
Message type, 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 noexcept |
The title of this error type. More... | |
int | maxErrors () const noexcept |
The maximum number of errors before program termination. More... | |
int | maxErrors (int nErrors) noexcept |
Set the maximum number of errors before program termination. More... | |
OSstream & | stream (OSstream *alternative=nullptr) |
Return OSstream for output operations. Use the alternative stream for serial-only output if it is a valid pointer. More... | |
OSstream & | masterStream (const label communicator) |
Return OSstream for output operations on the master process only, Snull on other processes. More... | |
std::ostream & | stdStream () |
Return std::ostream for output operations. More... | |
OSstream & | deprecated (const int afterVersion, const char *functionName, const char *sourceFileName, const int sourceFileLineNumber=0) |
Report deprecation (after specified API version) with 'From function-name, source file, line number'. More... | |
operator OSstream & () | |
Implicit cast to OSstream for << operations. More... | |
OSstream & | operator() () |
Explicitly convert to OSstream for << operations. More... | |
OSstream & | operator() (const std::string &functionName) |
Report 'From function-name'. More... | |
OSstream & | operator() (const char *functionName, const char *sourceFileName, const int sourceFileLineNumber=0) |
Report 'From function-name, source file, line number'. More... | |
OSstream & | operator() (const std::string &functionName, const char *sourceFileName, const int sourceFileLineNumber=0) |
Report 'From function-name, source file, line number'. More... | |
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. More... | |
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. More... | |
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. More... | |
Static Public Attributes | |
static int | level |
The output level (verbosity) of messages. More... | |
static int | redirect |
The output redirection of messages. More... | |
Protected Attributes | |
string | title_ |
errorSeverity | severity_ |
int | maxErrors_ |
int | errorCount_ |
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 70 of file messageStream.H.
enum errorSeverity |
Message type, error severity flags.
Definition at line 77 of file messageStream.H.
messageStream | ( | const string & | title, |
const errorSeverity | severity, | ||
const int | maxErrors = 0 |
||
) |
Construct from components.
Definition at line 44 of file messageStream.C.
|
explicit |
Construct as Fatal from dictionary, extracting the 'title'.
Definition at line 57 of file messageStream.C.
|
inlinenoexcept |
The title of this error type.
Definition at line 148 of file messageStream.H.
References messageStream::title_.
|
inlinenoexcept |
The maximum number of errors before program termination.
Definition at line 156 of file messageStream.H.
References messageStream::maxErrors_.
|
inlinenoexcept |
Set the maximum number of errors before program termination.
Definition at line 166 of file messageStream.H.
References messageStream::maxErrors_.
Foam::OSstream & stream | ( | OSstream * | alternative = nullptr | ) |
Return OSstream for output operations. Use the alternative
stream for serial-only output if it is a valid pointer.
Definition at line 68 of file messageStream.C.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Foam::infoDetailLevel, UPstream::master(), UPstream::parRun(), Foam::Perr, Foam::Pout, Foam::Serr, Foam::Snull, and Foam::Sout.
Referenced by objectRegistry::checkCacheTemporaryObjects(), messageStream::operator OSstream &(), messageStream::operator()(), and GAMGAgglomeration::printLevels().
Foam::OSstream & masterStream | ( | const label | communicator | ) |
Return OSstream for output operations on the master process only, Snull on other processes.
Definition at line 137 of file messageStream.C.
References Foam::endl(), UPstream::master(), Foam::Pout, error::printStack(), Foam::Snull, UPstream::warnComm, and UPstream::worldComm.
Referenced by viewFactor::calculate(), fvMatrix< Type >::fvSolver::solve(), smoothSolver::solve(), GAMGSolver::solve(), fvMatrix< Type >::solveCoupled(), fvMatrix< Type >::solver(), fvMatrix< Type >::solveSegregated(), and fvMatrix< Type >::solveSegregatedOrCoupled().
std::ostream & stdStream | ( | ) |
Return std::ostream for output operations.
Definition at line 154 of file messageStream.C.
Referenced by argList::argList(), argList::parse(), Foam::printTimingDetail(), and argList::printUsage().
Foam::OSstream & deprecated | ( | const int | afterVersion, |
const char * | functionName, | ||
const char * | sourceFileName, | ||
const int | sourceFileLineNumber = 0 |
||
) |
Report deprecation (after specified API version) with 'From function-name, source file, line number'.
Definition at line 180 of file messageStream.C.
References Foam::foamVersion::api, Foam::nl, and os().
|
inline |
Implicit cast to OSstream for << operations.
Definition at line 211 of file messageStream.H.
References messageStream::stream().
|
inline |
Explicitly convert to OSstream for << operations.
Definition at line 219 of file messageStream.H.
References messageStream::stream().
Foam::OSstream & operator() | ( | const std::string & | functionName | ) |
Report 'From function-name'.
Definition at line 163 of file messageStream.C.
References Foam::nl, and os().
Foam::OSstream & operator() | ( | const char * | functionName, |
const char * | sourceFileName, | ||
const int | sourceFileLineNumber = 0 |
||
) |
Report 'From function-name, source file, line number'.
Definition at line 231 of file messageStream.C.
References Foam::nl, and os().
Foam::OSstream & operator() | ( | const std::string & | functionName, |
const char * | sourceFileName, | ||
const int | sourceFileLineNumber = 0 |
||
) |
Report 'From function-name, source file, line number'.
Definition at line 250 of file messageStream.C.
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 266 of file messageStream.C.
References Foam::endl(), Foam::nl, 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 300 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 320 of file messageStream.C.
References dict, dictionary::endLineNumber(), dictionary::relativeName(), and dictionary::startLineNumber().
|
protected |
Definition at line 94 of file messageStream.H.
Referenced by messageStream::title().
|
protected |
Definition at line 95 of file messageStream.H.
|
protected |
Definition at line 96 of file messageStream.H.
Referenced by messageStream::maxErrors().
|
protected |
Definition at line 97 of file messageStream.H.
|
static |
The output level (verbosity) of messages.
Definition at line 114 of file messageStream.H.
Referenced by IOobject::setBad(), error::write(), and IOerror::write().
|
static |
The output redirection of messages.
Definition at line 122 of file messageStream.H.