1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
28 #include "dictionary.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 int Foam::messageStream::level(Foam::debug::debugSwitch("level", 2));
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 Foam::messageStream::messageStream
47 maxErrors_(maxErrors),
52 Foam::messageStream::messageStream(const dictionary& dict)
54 title_(dict.lookup("title")),
61 Foam::OSstream& Foam::messageStream::operator()
63 const char* functionName,
64 const char* sourceFileName,
65 const int sourceFileLineNumber
68 OSstream& os = operator OSstream&();
71 << " From function " << functionName << endl
72 << " in file " << sourceFileName
73 << " at line " << sourceFileLineNumber << endl
80 Foam::OSstream& Foam::messageStream::operator()
82 const string& functionName,
83 const char* sourceFileName,
84 const int sourceFileLineNumber
96 Foam::OSstream& Foam::messageStream::operator()
98 const char* functionName,
99 const char* sourceFileName,
100 const int sourceFileLineNumber,
101 const string& ioFileName,
102 const label ioStartLineNumber,
103 const label ioEndLineNumber
106 OSstream& os = operator OSstream&();
109 << " From function " << functionName << endl
110 << " in file " << sourceFileName
111 << " at line " << sourceFileLineNumber << endl
112 << " Reading " << ioFileName;
114 if (ioStartLineNumber >= 0 && ioEndLineNumber >= 0)
116 os << " from line " << ioStartLineNumber
117 << " to line " << ioEndLineNumber;
119 else if (ioStartLineNumber >= 0)
121 os << " at line " << ioStartLineNumber;
130 Foam::OSstream& Foam::messageStream::operator()
132 const char* functionName,
133 const char* sourceFileName,
134 const int sourceFileLineNumber,
135 const IOstream& ioStream
142 sourceFileLineNumber,
144 ioStream.lineNumber(),
150 Foam::OSstream& Foam::messageStream::operator()
152 const char* functionName,
153 const char* sourceFileName,
154 const int sourceFileLineNumber,
155 const dictionary& dict
162 sourceFileLineNumber,
164 dict.startLineNumber(),
170 Foam::messageStream::operator Foam::OSstream&()
174 bool collect = (severity_ == INFO || severity_ == WARNING);
177 if (!Pstream::master() && collect)
185 if (Pstream::parRun() && !collect)
187 Pout<< title().c_str();
191 Sout<< title().c_str();
199 if (errorCount_ >= maxErrors_)
201 FatalErrorIn("messageStream::operator OSstream&()")
203 << abort(FatalError);
207 if (Pstream::parRun() && !collect)
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 // Global messageStream definitions
225 Foam::messageStream Foam::SeriousError
227 "--> FOAM Serious Error : ",
228 messageStream::SERIOUS,
232 Foam::messageStream Foam::Warning
234 "--> FOAM Warning : ",
235 messageStream::WARNING
238 Foam::messageStream Foam::Info("", messageStream::INFO);
241 // ************************************************************************* //