messageStream: Added support for suppressing the printing of log header

This generalizes and replaces the previous "noBanner" option provided by argList
and is extended to include the messages printed by Time.

Resolves bug-report https://bugs.openfoam.org/view.php?id=2782
This commit is contained in:
Henry Weller
2017-12-06 11:58:35 +00:00
parent e85eb48ba7
commit cc4d4433b8
10 changed files with 49 additions and 44 deletions

View File

@ -26,7 +26,6 @@ Application
Description Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "argList.H" #include "argList.H"
@ -62,7 +61,8 @@ void printCleaning(fileName& pathName)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noBanner(); writeInfoHeader = false;
argList::noParallel(); argList::noParallel();
argList::validArgs.insert("fileName .. fileNameN"); argList::validArgs.insert("fileName .. fileNameN");
argList::addOption("istream", "file", "test Istream values"); argList::addOption("istream", "file", "test Istream values");

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -35,7 +35,8 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noBanner(); writeInfoHeader = false;
argList::noParallel(); argList::noParallel();
argList::validArgs.insert("file .. fileN"); argList::validArgs.insert("file .. fileN");

View File

@ -238,9 +238,9 @@ void remove(dictionary& dict, const dictionary& removeDict)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::addNote("manipulates dictionaries"); writeInfoHeader = false;
argList::noBanner(); argList::addNote("manipulates dictionaries");
argList::validArgs.append("dictionary file"); argList::validArgs.append("dictionary file");
argList::addBoolOption("keywords", "list keywords"); argList::addBoolOption("keywords", "list keywords");
argList::addOption("entry", "name", "report/select the named entry"); argList::addOption("entry", "name", "report/select the named entry");

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -49,10 +49,10 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::addNote("List times using timeSelector"); writeInfoHeader = false;
argList::addNote("List times using timeSelector");
timeSelector::addOptions(true, true); timeSelector::addOptions(true, true);
argList::noBanner();
argList::noParallel(); argList::noParallel();
argList::addBoolOption argList::addBoolOption
( (

View File

@ -68,12 +68,13 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
writeInfoHeader = false;
argList::addNote argList::addNote
( (
"information about surface meshes" "information about surface meshes"
); );
argList::noBanner();
argList::noParallel(); argList::noParallel();
argList::validArgs.append("surface file"); argList::validArgs.append("surface file");

View File

@ -48,7 +48,8 @@ void Foam::Time::readDict()
// Debug switches // Debug switches
if (controlDict_.found("DebugSwitches")) if (controlDict_.found("DebugSwitches"))
{ {
Info<< "Overriding DebugSwitches according to " << controlDict_.name() InfoHeader
<< "Overriding DebugSwitches according to " << controlDict_.name()
<< endl; << endl;
simpleObjectRegistry& objects = debug::debugObjects(); simpleObjectRegistry& objects = debug::debugObjects();
@ -61,7 +62,7 @@ void Foam::Time::readDict()
if (objPtr) if (objPtr)
{ {
Info<< " " << iter() << endl; InfoHeader << " " << iter() << endl;
const List<simpleRegIOobject*>& objects = *objPtr; const List<simpleRegIOobject*>& objects = *objPtr;
@ -89,7 +90,8 @@ void Foam::Time::readDict()
// Optimisation Switches // Optimisation Switches
if (controlDict_.found("OptimisationSwitches")) if (controlDict_.found("OptimisationSwitches"))
{ {
Info<< "Overriding OptimisationSwitches according to " InfoHeader
<< "Overriding OptimisationSwitches according to "
<< controlDict_.name() << endl; << controlDict_.name() << endl;
simpleObjectRegistry& objects = debug::optimisationObjects(); simpleObjectRegistry& objects = debug::optimisationObjects();
@ -105,7 +107,7 @@ void Foam::Time::readDict()
if (objPtr) if (objPtr)
{ {
Info<< " " << iter() << endl; InfoHeader << " " << iter() << endl;
const List<simpleRegIOobject*>& objects = *objPtr; const List<simpleRegIOobject*>& objects = *objPtr;
@ -150,7 +152,8 @@ void Foam::Time::readDict()
controlDict_.watchIndices().clear(); controlDict_.watchIndices().clear();
// Installing the new handler // Installing the new handler
Info<< "Overriding fileHandler to " << fileHandlerName << endl; InfoHeader
<< "Overriding fileHandler to " << fileHandlerName << endl;
autoPtr<fileOperation> handler autoPtr<fileOperation> handler
( (
@ -172,7 +175,8 @@ void Foam::Time::readDict()
// the 'unitSet' might be changed and the individual values // the 'unitSet' might be changed and the individual values
if (controlDict_.found("DimensionedConstants")) if (controlDict_.found("DimensionedConstants"))
{ {
Info<< "Overriding DimensionedConstants according to " InfoHeader
<< "Overriding DimensionedConstants according to "
<< controlDict_.name() << endl; << controlDict_.name() << endl;
// Change in-memory // Change in-memory
@ -194,18 +198,23 @@ void Foam::Time::readDict()
{ {
objects[i]->readData(dummyIs); objects[i]->readData(dummyIs);
if (writeInfoHeader)
{
Info<< " "; Info<< " ";
objects[i]->writeData(Info); objects[i]->writeData(Info);
Info<< endl; Info<< endl;
} }
} }
} }
}
// Dimension sets // Dimension sets
if (controlDict_.found("DimensionSets")) if (controlDict_.found("DimensionSets"))
{ {
Info<< "Overriding DimensionSets according to " InfoHeader
<< "Overriding DimensionSets according to "
<< controlDict_.name() << endl; << controlDict_.name() << endl;
dictionary dict(Foam::dimensionSystems()); dictionary dict(Foam::dimensionSystems());
@ -217,7 +226,7 @@ void Foam::Time::readDict()
if (objPtr) if (objPtr)
{ {
Info<< controlDict_.subDict("DimensionSets") << endl; InfoHeader << controlDict_.subDict("DimensionSets") << endl;
const List<simpleRegIOobject*>& objects = *objPtr; const List<simpleRegIOobject*>& objects = *objPtr;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -254,5 +254,6 @@ Foam::messageStream Foam::Warning
Foam::messageStream Foam::Info("", messageStream::INFO); Foam::messageStream Foam::Info("", messageStream::INFO);
bool Foam::writeInfoHeader = true;
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -206,6 +206,7 @@ public:
extern messageStream SeriousError; extern messageStream SeriousError;
extern messageStream Warning; extern messageStream Warning;
extern messageStream Info; extern messageStream Info;
extern bool writeInfoHeader;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -281,6 +282,10 @@ extern messageStream Info;
// for FUNCTION_NAME in file __FILE__ at line __LINE__ // for FUNCTION_NAME in file __FILE__ at line __LINE__
#define InfoInFunction InfoIn(FUNCTION_NAME) #define InfoInFunction InfoIn(FUNCTION_NAME)
//- Report write to Foam::Info if the local log switch is true
#define InfoHeader \
if (::Foam::writeInfoHeader) Info
//- Report write to Foam::Info if the local log switch is true //- Report write to Foam::Info if the local log switch is true
#define Log \ #define Log \
if (log) Info if (log) Info

View File

@ -39,7 +39,6 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
bool Foam::argList::bannerEnabled = true;
Foam::SLList<Foam::string> Foam::argList::validArgs; Foam::SLList<Foam::string> Foam::argList::validArgs;
Foam::HashTable<Foam::string> Foam::argList::validOptions; Foam::HashTable<Foam::string> Foam::argList::validOptions;
Foam::HashTable<Foam::string> Foam::argList::validParOptions; Foam::HashTable<Foam::string> Foam::argList::validParOptions;
@ -145,12 +144,6 @@ void Foam::argList::removeOption(const word& opt)
} }
void Foam::argList::noBanner()
{
bannerEnabled = false;
}
void Foam::argList::noParallel() void Foam::argList::noParallel()
{ {
removeOption("parallel"); removeOption("parallel");
@ -557,7 +550,7 @@ void Foam::argList::parse
string timeString = clock::clockTime(); string timeString = clock::clockTime();
// Print the banner once only for parallel runs // Print the banner once only for parallel runs
if (Pstream::master() && bannerEnabled) if (Pstream::master() && writeInfoHeader)
{ {
IOobject::writeBanner(Info, true) IOobject::writeBanner(Info, true)
<< "Build : " << Foam::FOAMbuild << nl << "Build : " << Foam::FOAMbuild << nl
@ -615,7 +608,7 @@ void Foam::argList::parse
fileOperation::New fileOperation::New
( (
handlerType, handlerType,
bannerEnabled writeInfoHeader
) )
); );
Foam::fileHandler(handler); Foam::fileHandler(handler);
@ -867,7 +860,7 @@ void Foam::argList::parse
} }
if (Pstream::master() && bannerEnabled) if (Pstream::master() && writeInfoHeader)
{ {
Info<< "Case : " << (rootPath_/globalCase_).c_str() << nl Info<< "Case : " << (rootPath_/globalCase_).c_str() << nl
<< "nProcs : " << nProcs << endl; << "nProcs : " << nProcs << endl;
@ -906,12 +899,12 @@ void Foam::argList::parse
// Switch on signal trapping. We have to wait until after Pstream::init // Switch on signal trapping. We have to wait until after Pstream::init
// since this sets up its own ones. // since this sets up its own ones.
sigFpe_.set(bannerEnabled); sigFpe_.set(writeInfoHeader);
sigInt_.set(bannerEnabled); sigInt_.set(writeInfoHeader);
sigQuit_.set(bannerEnabled); sigQuit_.set(writeInfoHeader);
sigSegv_.set(bannerEnabled); sigSegv_.set(writeInfoHeader);
if (bannerEnabled) if (writeInfoHeader)
{ {
Info<< "fileModificationChecking : " Info<< "fileModificationChecking : "
<< "Monitoring run-time modified files using " << "Monitoring run-time modified files using "
@ -948,7 +941,7 @@ void Foam::argList::parse
} }
} }
if (Pstream::master() && bannerEnabled) if (Pstream::master() && writeInfoHeader)
{ {
Info<< endl; Info<< endl;
IOobject::writeDivider(Info); IOobject::writeDivider(Info);

View File

@ -104,8 +104,6 @@ class argList
{ {
// Private data // Private data
static bool bannerEnabled;
//- Switch on/off parallel mode. Has to be first to be constructed //- Switch on/off parallel mode. Has to be first to be constructed
// so destructor is done last. // so destructor is done last.
ParRunControl parRunControl_; ParRunControl parRunControl_;
@ -357,9 +355,6 @@ public:
//- Remove option from validOptions and from optionUsage //- Remove option from validOptions and from optionUsage
static void removeOption(const word& opt); static void removeOption(const word& opt);
//- Disable emitting the banner information
static void noBanner();
//- Remove the parallel options //- Remove the parallel options
static void noParallel(); static void noParallel();