From cc4d4433b80f947006a18e584cee2d011057a3dc Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Wed, 6 Dec 2017 11:58:35 +0000 Subject: [PATCH] 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 --- .../test/fileNameClean/Test-fileNameClean.C | 4 +-- applications/test/mvBak/Test-mvBak.C | 5 +-- .../foamDictionary/foamDictionary.C | 4 +-- .../foamListTimes/foamListTimes.C | 6 ++-- .../surface/surfaceMeshInfo/surfaceMeshInfo.C | 3 +- src/OpenFOAM/db/Time/TimeIO.C | 31 ++++++++++++------- src/OpenFOAM/db/error/messageStream.C | 3 +- src/OpenFOAM/db/error/messageStream.H | 7 ++++- src/OpenFOAM/global/argList/argList.C | 25 ++++++--------- src/OpenFOAM/global/argList/argList.H | 5 --- 10 files changed, 49 insertions(+), 44 deletions(-) diff --git a/applications/test/fileNameClean/Test-fileNameClean.C b/applications/test/fileNameClean/Test-fileNameClean.C index 9441beecc..fbb06fd32 100644 --- a/applications/test/fileNameClean/Test-fileNameClean.C +++ b/applications/test/fileNameClean/Test-fileNameClean.C @@ -26,7 +26,6 @@ Application Description - \*---------------------------------------------------------------------------*/ #include "argList.H" @@ -62,7 +61,8 @@ void printCleaning(fileName& pathName) int main(int argc, char *argv[]) { - argList::noBanner(); + writeInfoHeader = false; + argList::noParallel(); argList::validArgs.insert("fileName .. fileNameN"); argList::addOption("istream", "file", "test Istream values"); diff --git a/applications/test/mvBak/Test-mvBak.C b/applications/test/mvBak/Test-mvBak.C index ab0f70f6e..f4b4a1782 100644 --- a/applications/test/mvBak/Test-mvBak.C +++ b/applications/test/mvBak/Test-mvBak.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,7 +35,8 @@ using namespace Foam; int main(int argc, char *argv[]) { - argList::noBanner(); + writeInfoHeader = false; + argList::noParallel(); argList::validArgs.insert("file .. fileN"); diff --git a/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C b/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C index 03ff9964d..8681a4a8a 100644 --- a/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C +++ b/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C @@ -238,9 +238,9 @@ void remove(dictionary& dict, const dictionary& removeDict) int main(int argc, char *argv[]) { - argList::addNote("manipulates dictionaries"); + writeInfoHeader = false; - argList::noBanner(); + argList::addNote("manipulates dictionaries"); argList::validArgs.append("dictionary file"); argList::addBoolOption("keywords", "list keywords"); argList::addOption("entry", "name", "report/select the named entry"); diff --git a/applications/utilities/miscellaneous/foamListTimes/foamListTimes.C b/applications/utilities/miscellaneous/foamListTimes/foamListTimes.C index f395c5966..9642c664e 100644 --- a/applications/utilities/miscellaneous/foamListTimes/foamListTimes.C +++ b/applications/utilities/miscellaneous/foamListTimes/foamListTimes.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -49,10 +49,10 @@ using namespace Foam; int main(int argc, char *argv[]) { - argList::addNote("List times using timeSelector"); + writeInfoHeader = false; + argList::addNote("List times using timeSelector"); timeSelector::addOptions(true, true); - argList::noBanner(); argList::noParallel(); argList::addBoolOption ( diff --git a/applications/utilities/surface/surfaceMeshInfo/surfaceMeshInfo.C b/applications/utilities/surface/surfaceMeshInfo/surfaceMeshInfo.C index 9953e5fc4..4a04775f0 100644 --- a/applications/utilities/surface/surfaceMeshInfo/surfaceMeshInfo.C +++ b/applications/utilities/surface/surfaceMeshInfo/surfaceMeshInfo.C @@ -68,12 +68,13 @@ using namespace Foam; int main(int argc, char *argv[]) { + writeInfoHeader = false; + argList::addNote ( "information about surface meshes" ); - argList::noBanner(); argList::noParallel(); argList::validArgs.append("surface file"); diff --git a/src/OpenFOAM/db/Time/TimeIO.C b/src/OpenFOAM/db/Time/TimeIO.C index c8a6f4789..aef4710f6 100644 --- a/src/OpenFOAM/db/Time/TimeIO.C +++ b/src/OpenFOAM/db/Time/TimeIO.C @@ -48,7 +48,8 @@ void Foam::Time::readDict() // Debug switches if (controlDict_.found("DebugSwitches")) { - Info<< "Overriding DebugSwitches according to " << controlDict_.name() + InfoHeader + << "Overriding DebugSwitches according to " << controlDict_.name() << endl; simpleObjectRegistry& objects = debug::debugObjects(); @@ -61,7 +62,7 @@ void Foam::Time::readDict() if (objPtr) { - Info<< " " << iter() << endl; + InfoHeader << " " << iter() << endl; const List& objects = *objPtr; @@ -89,7 +90,8 @@ void Foam::Time::readDict() // Optimisation Switches if (controlDict_.found("OptimisationSwitches")) { - Info<< "Overriding OptimisationSwitches according to " + InfoHeader + << "Overriding OptimisationSwitches according to " << controlDict_.name() << endl; simpleObjectRegistry& objects = debug::optimisationObjects(); @@ -105,7 +107,7 @@ void Foam::Time::readDict() if (objPtr) { - Info<< " " << iter() << endl; + InfoHeader << " " << iter() << endl; const List& objects = *objPtr; @@ -150,7 +152,8 @@ void Foam::Time::readDict() controlDict_.watchIndices().clear(); // Installing the new handler - Info<< "Overriding fileHandler to " << fileHandlerName << endl; + InfoHeader + << "Overriding fileHandler to " << fileHandlerName << endl; autoPtr handler ( @@ -172,7 +175,8 @@ void Foam::Time::readDict() // the 'unitSet' might be changed and the individual values if (controlDict_.found("DimensionedConstants")) { - Info<< "Overriding DimensionedConstants according to " + InfoHeader + << "Overriding DimensionedConstants according to " << controlDict_.name() << endl; // Change in-memory @@ -194,9 +198,13 @@ void Foam::Time::readDict() { objects[i]->readData(dummyIs); - Info<< " "; - objects[i]->writeData(Info); - Info<< endl; + if (writeInfoHeader) + { + + Info<< " "; + objects[i]->writeData(Info); + Info<< endl; + } } } } @@ -205,7 +213,8 @@ void Foam::Time::readDict() // Dimension sets if (controlDict_.found("DimensionSets")) { - Info<< "Overriding DimensionSets according to " + InfoHeader + << "Overriding DimensionSets according to " << controlDict_.name() << endl; dictionary dict(Foam::dimensionSystems()); @@ -217,7 +226,7 @@ void Foam::Time::readDict() if (objPtr) { - Info<< controlDict_.subDict("DimensionSets") << endl; + InfoHeader << controlDict_.subDict("DimensionSets") << endl; const List& objects = *objPtr; diff --git a/src/OpenFOAM/db/error/messageStream.C b/src/OpenFOAM/db/error/messageStream.C index 7ca86cc7a..55950a714 100644 --- a/src/OpenFOAM/db/error/messageStream.C +++ b/src/OpenFOAM/db/error/messageStream.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -254,5 +254,6 @@ Foam::messageStream Foam::Warning Foam::messageStream Foam::Info("", messageStream::INFO); +bool Foam::writeInfoHeader = true; // ************************************************************************* // diff --git a/src/OpenFOAM/db/error/messageStream.H b/src/OpenFOAM/db/error/messageStream.H index 54ef0fe66..7ea5302e4 100644 --- a/src/OpenFOAM/db/error/messageStream.H +++ b/src/OpenFOAM/db/error/messageStream.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -206,6 +206,7 @@ public: extern messageStream SeriousError; extern messageStream Warning; extern messageStream Info; +extern bool writeInfoHeader; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -281,6 +282,10 @@ extern messageStream Info; // for FUNCTION_NAME in file __FILE__ at line __LINE__ #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 #define Log \ if (log) Info diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 648c51a45..b94e0ee46 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -39,7 +39,6 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -bool Foam::argList::bannerEnabled = true; Foam::SLList Foam::argList::validArgs; Foam::HashTable Foam::argList::validOptions; Foam::HashTable Foam::argList::validParOptions; @@ -145,12 +144,6 @@ void Foam::argList::removeOption(const word& opt) } -void Foam::argList::noBanner() -{ - bannerEnabled = false; -} - - void Foam::argList::noParallel() { removeOption("parallel"); @@ -557,7 +550,7 @@ void Foam::argList::parse string timeString = clock::clockTime(); // Print the banner once only for parallel runs - if (Pstream::master() && bannerEnabled) + if (Pstream::master() && writeInfoHeader) { IOobject::writeBanner(Info, true) << "Build : " << Foam::FOAMbuild << nl @@ -615,7 +608,7 @@ void Foam::argList::parse fileOperation::New ( handlerType, - bannerEnabled + writeInfoHeader ) ); 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 << "nProcs : " << nProcs << endl; @@ -906,12 +899,12 @@ void Foam::argList::parse // Switch on signal trapping. We have to wait until after Pstream::init // since this sets up its own ones. - sigFpe_.set(bannerEnabled); - sigInt_.set(bannerEnabled); - sigQuit_.set(bannerEnabled); - sigSegv_.set(bannerEnabled); + sigFpe_.set(writeInfoHeader); + sigInt_.set(writeInfoHeader); + sigQuit_.set(writeInfoHeader); + sigSegv_.set(writeInfoHeader); - if (bannerEnabled) + if (writeInfoHeader) { Info<< "fileModificationChecking : " << "Monitoring run-time modified files using " @@ -948,7 +941,7 @@ void Foam::argList::parse } } - if (Pstream::master() && bannerEnabled) + if (Pstream::master() && writeInfoHeader) { Info<< endl; IOobject::writeDivider(Info); diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H index b85b9b203..eea7fcf54 100644 --- a/src/OpenFOAM/global/argList/argList.H +++ b/src/OpenFOAM/global/argList/argList.H @@ -104,8 +104,6 @@ class argList { // Private data - static bool bannerEnabled; - //- Switch on/off parallel mode. Has to be first to be constructed // so destructor is done last. ParRunControl parRunControl_; @@ -357,9 +355,6 @@ public: //- Remove option from validOptions and from optionUsage static void removeOption(const word& opt); - //- Disable emitting the banner information - static void noBanner(); - //- Remove the parallel options static void noParallel();