71 errorSeverity severity,
76 messageStream(severity, maxErrors, use_stderr)
88 errorSeverity severity,
113 if (communicator < 0)
121 const bool masterOnly
124 || ((severity_ & ~errorSeverity::USE_STDERR) == errorSeverity::INFO)
125 || ((severity_ & ~errorSeverity::USE_STDERR) == errorSeverity::WARNING)
144 const bool use_stderr =
147 || (severity_ & errorSeverity::USE_STDERR)
166 osptr = (use_stderr ? &
Perr : &
Pout);
171 (*osptr) << title_.c_str();
174 if (maxErrors_ && (++errorCount_ >= maxErrors_))
177 <<
"Too many errors..."
190 if (communicator < 0)
197 Perr<<
"** messageStream with comm:" << communicator <<
endl;
203 return this->
stream(
nullptr, communicator);
213 return this->
stream().stdStream();
221 const int afterVersion,
222 const char* functionName,
223 const char* sourceFileName,
224 const int sourceFileLineNumber
239 - (12 * (afterVersion/100) + (afterVersion % 100))
243 <<
">>> DEPRECATED after version " << afterVersion;
245 if (afterVersion < 1000)
248 os <<
". This is very old! <<<" <<
nl;
252 os <<
". This is about " << months <<
" months old. <<<" <<
nl;
261 os <<
" From " << functionName <<
nl;
265 os <<
" in file " << sourceFileName;
267 if (sourceFileLineNumber >= 0)
269 os <<
" at line " << sourceFileLineNumber;
282 const std::string& functionName,
283 const char* sourceFileName,
284 const int sourceFileLineNumber
287 OSstream&
os = this->stream();
289 if (!functionName.empty())
292 <<
" From " << functionName.c_str() <<
nl;
297 os <<
" in file " << sourceFileName;
299 if (sourceFileLineNumber >= 0)
301 os <<
" at line " << sourceFileLineNumber;
312 const char* functionName,
313 const char* sourceFileName,
314 const int sourceFileLineNumber
317 OSstream&
os = this->stream();
322 <<
" From " << functionName <<
nl;
327 os <<
" in file " << sourceFileName;
329 if (sourceFileLineNumber >= 0)
331 os <<
" at line " << sourceFileLineNumber;
342 const char* functionName,
343 const char* sourceFileName,
344 const int sourceFileLineNumber,
345 const std::string& ioFileName,
346 const label ioStartLineNumber,
347 const label ioEndLineNumber
350 OSstream&
os = operator()
357 os <<
"Reading \"" << ioFileName.c_str() <<
'"';
359 if (ioStartLineNumber >= 0)
361 os <<
" at line " << ioStartLineNumber;
363 if (ioStartLineNumber < ioEndLineNumber)
365 os <<
" to " << ioEndLineNumber;
377 const char* functionName,
378 const char* sourceFileName,
379 const int sourceFileLineNumber,
387 sourceFileLineNumber,
388 ioStream.relativeName(),
389 ioStream.lineNumber(),
397 const char* functionName,
398 const char* sourceFileName,
399 const int sourceFileLineNumber,
407 sourceFileLineNumber,
409 dict.startLineNumber(),
433 "--> FOAM Warning : ",
439 "--> FOAM Serious Error : ",
An IOstream is an abstract base class for all input/output systems; be they streams,...
Generic output stream using a standard (STL) stream.
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static label warnComm
Debugging: warn for use of any communicator differing from warnComm.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
static bool & parRun() noexcept
Test if this a parallel run.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
static void printStack(Ostream &os, int size=-1)
Helper function to print a stack, with optional upper limit.
Handle output messages in a simple, consistent stream-based manner.
messageStream(errorSeverity severity, int maxErrors=0, bool use_stderr=false)
Construct untitled with given characteristics.
int errorCount_
The current number of errors counted.
int maxErrors() const noexcept
The maximum number of errors before program termination.
int severity_
The message type / error severity, possibly with USE_STDERR mask.
std::ostream & stdStream()
Return std::ostream for output operations.
OSstream & stream(OSstream *alternative=nullptr, int communicator=-1)
Return OSstream 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,...
errorSeverity
Message type, error severity flags.
@ USE_STDERR
Bitmask for stderr output (for the above enums).
@ INFO
General information output (stdout).
@ WARNING
Warning of possible problem.
@ SERIOUS
A serious problem - eg, data corruption.
OSstream & masterStream(int communicator)
Return OSstream for output operations on the master process only, Snull on other processes.
int maxErrors_
The maximum number of errors before program termination.
static int level
The output level (verbosity) of messages.
static int redirect
The output redirection of messages.
const string & title() const noexcept
The title of this error type.
string title_
The title of this error type.
A class for handling character strings derived from std::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
int infoSwitch(const char *name, const int deflt=0)
Lookup info switch or add default value.
const int api
OpenFOAM api number (integer) corresponding to the value of OPENFOAM at the time of compilation.
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
messageStream Info
Information stream (stdout output on master, null elsewhere).
OFstream Snull
Global predefined null output stream "/dev/null".
OSstream Sout
OSstream wrapped stdout (std::cout).
Ostream & endl(Ostream &os)
Add newline and flush stream.
messageStream SeriousError
Error stream (stdout output on all processes), with additional 'FOAM Serious Error' header text.
OSstream Serr
OSstream wrapped stderr (std::cerr).
errorManip< error > abort(error &err)
int infoDetailLevel
Global for selective suppression of Info output.
messageStream InfoErr
Information stream (stderr output on master, null elsewhere).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text.
constexpr char nl
The newline '\n' character (0x0a).