mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add api/patch information to FatalError (#1880)
- can be useful when confronted with partial outputs - provision for redirecting error/warning
This commit is contained in:
@ -268,9 +268,16 @@ void Foam::IOerror::write(Ostream& os, const bool includeTitle) const
|
||||
os << nl;
|
||||
if (includeTitle && !title().empty())
|
||||
{
|
||||
os << title().c_str() << nl;
|
||||
}
|
||||
os << title().c_str()
|
||||
<< "(openfoam-" << foamVersion::api;
|
||||
|
||||
if (foamVersion::patched())
|
||||
{
|
||||
// Patch-level, when defined
|
||||
os << " patch=" << foamVersion::patch.c_str();
|
||||
}
|
||||
os << ')' << nl;
|
||||
}
|
||||
os << message().c_str();
|
||||
|
||||
|
||||
|
||||
@ -300,7 +300,15 @@ void Foam::error::write(Ostream& os, const bool includeTitle) const
|
||||
os << nl;
|
||||
if (includeTitle && !title().empty())
|
||||
{
|
||||
os << title().c_str() << nl;
|
||||
os << title().c_str()
|
||||
<< "(openfoam-" << foamVersion::api;
|
||||
|
||||
if (foamVersion::patched())
|
||||
{
|
||||
// Patch-level, when defined
|
||||
os << " patch=" << foamVersion::patch.c_str();
|
||||
}
|
||||
os << ')' << nl;
|
||||
}
|
||||
os << message().c_str();
|
||||
|
||||
|
||||
@ -35,6 +35,8 @@ License
|
||||
// Default is 2 : report source file name and line number if available
|
||||
int Foam::messageStream::level(Foam::debug::debugSwitch("level", 2));
|
||||
|
||||
int Foam::messageStream::redirect(0);
|
||||
|
||||
// Default is 1 : report to Info
|
||||
int Foam::infoDetailLevel(1);
|
||||
|
||||
@ -212,35 +214,33 @@ Foam::messageStream::operator Foam::OSstream&()
|
||||
{
|
||||
if (level)
|
||||
{
|
||||
// stderr instead of stdout
|
||||
// - INFO_STDERR
|
||||
// - WARNING when infoDetailLevel == 0
|
||||
const bool useSerr =
|
||||
(
|
||||
(severity_ == INFO_STDERR)
|
||||
|| (severity_ == WARNING && Foam::infoDetailLevel == 0)
|
||||
);
|
||||
|
||||
const bool collect =
|
||||
(
|
||||
severity_ == INFO
|
||||
|| severity_ == WARNING
|
||||
|| useSerr
|
||||
|| severity_ == INFO_STDERR
|
||||
);
|
||||
|
||||
|
||||
// Could add guard with parRun
|
||||
if (collect && !Pstream::master())
|
||||
{
|
||||
return Snull;
|
||||
}
|
||||
|
||||
// Use stderr instead of stdout
|
||||
// - INFO_STDERR
|
||||
// - WARNING when infoDetailLevel == 0
|
||||
const bool useStderr =
|
||||
(
|
||||
(severity_ == INFO_STDERR)
|
||||
|| (severity_ == WARNING && Foam::infoDetailLevel == 0)
|
||||
);
|
||||
|
||||
OSstream& os =
|
||||
(
|
||||
(collect || !Pstream::parRun())
|
||||
? (useSerr ? Serr : Sout)
|
||||
: Pout
|
||||
? (useStderr ? Serr : Sout)
|
||||
: (useStderr ? Perr : Pout)
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -98,7 +98,7 @@ public:
|
||||
|
||||
// Static Data
|
||||
|
||||
//- Control the output verbosity of messageStream
|
||||
//- The output level (verbosity) of messages
|
||||
//
|
||||
// - level == 0 : suppress all output
|
||||
// - level == 1 : normal output
|
||||
@ -107,6 +107,11 @@ public:
|
||||
// \note The default level is normally 2.
|
||||
static int level;
|
||||
|
||||
//- The output redirection of messages
|
||||
//
|
||||
// - redirect == 2 : use stderr instead of stdout
|
||||
static int redirect;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
|
||||
Reference in New Issue
Block a user