1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
27 #include "dictionary.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 int Foam::messageStream::level(Foam::debug::debugSwitch("level", 2));
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 Foam::messageStream::messageStream
46 maxErrors_(maxErrors),
51 Foam::messageStream::messageStream(const dictionary& dict)
53 title_(dict.lookup("title")),
60 Foam::OSstream& Foam::messageStream::operator()
62 const char* functionName,
63 const char* sourceFileName,
64 const int sourceFileLineNumber
67 OSstream& os = operator OSstream&();
70 << " From function " << functionName << endl
71 << " in file " << sourceFileName
72 << " at line " << sourceFileLineNumber << endl
79 Foam::OSstream& Foam::messageStream::operator()
81 const string& functionName,
82 const char* sourceFileName,
83 const int sourceFileLineNumber
95 Foam::OSstream& Foam::messageStream::operator()
97 const char* functionName,
98 const char* sourceFileName,
99 const int sourceFileLineNumber,
100 const string& ioFileName,
101 const label ioStartLineNumber,
102 const label ioEndLineNumber
105 OSstream& os = operator OSstream&();
108 << " From function " << functionName << endl
109 << " in file " << sourceFileName
110 << " at line " << sourceFileLineNumber << endl
111 << " Reading " << ioFileName;
113 if (ioStartLineNumber >= 0 && ioEndLineNumber >= 0)
115 os << " from line " << ioStartLineNumber
116 << " to line " << ioEndLineNumber;
118 else if (ioStartLineNumber >= 0)
120 os << " at line " << ioStartLineNumber;
129 Foam::OSstream& Foam::messageStream::operator()
131 const char* functionName,
132 const char* sourceFileName,
133 const int sourceFileLineNumber,
134 const IOstream& ioStream
141 sourceFileLineNumber,
143 ioStream.lineNumber(),
149 Foam::OSstream& Foam::messageStream::operator()
151 const char* functionName,
152 const char* sourceFileName,
153 const int sourceFileLineNumber,
154 const dictionary& dict
161 sourceFileLineNumber,
163 dict.startLineNumber(),
169 Foam::messageStream::operator Foam::OSstream&()
173 bool collect = (severity_ == INFO || severity_ == WARNING);
176 if (!Pstream::master() && collect)
184 if (Pstream::parRun() && !collect)
186 Pout<< title().c_str();
190 Sout<< title().c_str();
198 if (errorCount_ >= maxErrors_)
200 FatalErrorIn("messageStream::operator OSstream&()")
202 << abort(FatalError);
206 if (Pstream::parRun() && !collect)
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 // Global messageStream definitions
224 Foam::messageStream Foam::SeriousError
226 "--> FOAM Serious Error : ",
227 messageStream::SERIOUS,
231 Foam::messageStream Foam::Warning
233 "--> FOAM Warning : ",
234 messageStream::WARNING
237 Foam::messageStream Foam::Info("", messageStream::INFO);
240 // ************************************************************************* //