@@ -32,16 +32,31 @@ ErrorLogger::ErrorMessage::ErrorMessage(const std::list<FileLocation> &callStack
3232{
3333 _callStack = callStack;
3434 _severity = severity;
35- _msg = msg;
35+ setmsg ( msg) ;
3636 _id = id;
3737}
3838
39+ void ErrorLogger::ErrorMessage::setmsg (const std::string &msg)
40+ {
41+ const std::string::size_type pos = msg.find (" \n " );
42+ if (pos == std::string::npos)
43+ {
44+ _shortMessage = msg;
45+ _verboseMessage = msg;
46+ }
47+ else
48+ {
49+ _shortMessage = msg.substr (0 , pos - 1 );
50+ _verboseMessage = msg.substr (pos + 1 );
51+ }
52+ }
53+
3954std::string ErrorLogger::ErrorMessage::serialize () const
4055{
4156 std::ostringstream oss;
4257 oss << _id.length () << " " << _id;
4358 oss << Severity::toString (_severity).length () << " " << Severity::toString (_severity);
44- oss << _msg .length () << " " << _msg ;
59+ oss << _shortMessage .length () << " " << _shortMessage ;
4560 oss << _callStack.size () << " " ;
4661
4762 for (std::list<ErrorLogger::ErrorMessage::FileLocation>::const_iterator tok = _callStack.begin (); tok != _callStack.end (); ++tok)
@@ -79,7 +94,7 @@ bool ErrorLogger::ErrorMessage::deserialize(const std::string &data)
7994
8095 _id = results[0 ];
8196 _severity = Severity::fromString (results[1 ]);
82- _msg = results[2 ];
97+ _shortMessage = results[2 ];
8398
8499 unsigned int stackSize = 0 ;
85100 if (!(iss >> stackSize))
@@ -146,7 +161,7 @@ static std::string stringToXml(std::string s)
146161 return s;
147162}
148163
149- std::string ErrorLogger::ErrorMessage::toXML () const
164+ std::string ErrorLogger::ErrorMessage::toXML (bool verbose ) const
150165{
151166 std::ostringstream xml;
152167 xml << " <error" ;
@@ -157,7 +172,7 @@ std::string ErrorLogger::ErrorMessage::toXML() const
157172 }
158173 xml << " id=\" " << _id << " \" " ;
159174 xml << " severity=\" " << (_severity == Severity::error ? " error" : " style" ) << " \" " ;
160- xml << " msg=\" " << stringToXml (_msg ) << " \" " ;
175+ xml << " msg=\" " << stringToXml (verbose ? _verboseMessage : _shortMessage ) << " \" " ;
161176 xml << " />" ;
162177 return xml.str ();
163178}
@@ -172,7 +187,7 @@ void ErrorLogger::ErrorMessage::findAndReplace(std::string &source, const std::s
172187 }
173188}
174189
175- std::string ErrorLogger::ErrorMessage::toString (const std::string &outputFormat) const
190+ std::string ErrorLogger::ErrorMessage::toString (bool verbose, const std::string &outputFormat) const
176191{
177192 if (outputFormat.length () == 0 )
178193 {
@@ -181,15 +196,15 @@ std::string ErrorLogger::ErrorMessage::toString(const std::string &outputFormat)
181196 text << callStackToString (_callStack) << " : " ;
182197 if (_severity != Severity::none)
183198 text << " (" << Severity::toString (_severity) << " ) " ;
184- text << _msg ;
199+ text << (verbose ? _verboseMessage : _shortMessage) ;
185200 return text.str ();
186201 }
187202 else
188203 {
189204 std::string result = outputFormat;
190205 findAndReplace (result, " {id}" , _id);
191206 findAndReplace (result, " {severity}" , Severity::toString (_severity));
192- findAndReplace (result, " {message}" , _msg );
207+ findAndReplace (result, " {message}" , verbose ? _verboseMessage : _shortMessage );
193208
194209 if (!_callStack.empty ())
195210 {
0 commit comments