Merge pull request #74 from kimmov/errorlogger

Refactoring information messages.
This commit is contained in:
Daniel Marjamäki 2012-06-19 11:19:59 -07:00
commit 180bb00ac6
8 changed files with 41 additions and 6 deletions

View File

@ -207,7 +207,7 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
"--check-config.", "--check-config.",
"missingInclude", "missingInclude",
false); false);
reportErr(msg); reportInfo(msg);
} }
} }
@ -265,6 +265,11 @@ void CppCheckExecutor::reportProgress(const std::string &filename, const char st
} }
} }
void CppCheckExecutor::reportInfo(const ErrorLogger::ErrorMessage &msg)
{
reportOut(msg.toXML(false, _settings._xml_version));
}
void CppCheckExecutor::reportStatus(size_t fileindex, size_t filecount, size_t sizedone, size_t sizetotal) void CppCheckExecutor::reportStatus(size_t fileindex, size_t filecount, size_t sizedone, size_t sizetotal)
{ {
if (filecount > 1) { if (filecount > 1) {

View File

@ -72,6 +72,11 @@ public:
void reportProgress(const std::string &filename, const char stage[], const unsigned int value); void reportProgress(const std::string &filename, const char stage[], const unsigned int value);
/**
* Output information messages.
*/
virtual void reportInfo(const ErrorLogger::ErrorMessage &msg);
/** /**
* Information about how many files have been checked * Information about how many files have been checked
* *

View File

@ -290,6 +290,11 @@ void ThreadExecutor::reportErr(const ErrorLogger::ErrorMessage &msg)
writeToPipe(REPORT_ERROR, msg.serialize()); writeToPipe(REPORT_ERROR, msg.serialize());
} }
void ThreadExecutor::reportInfo(const ErrorLogger::ErrorMessage &msg)
{
writeToPipe(REPORT_OUT, msg.serialize());
}
#else #else
void ThreadExecutor::addFileContent(const std::string &/*path*/, const std::string &/*content*/) void ThreadExecutor::addFileContent(const std::string &/*path*/, const std::string &/*content*/)
@ -311,4 +316,9 @@ void ThreadExecutor::reportErr(const ErrorLogger::ErrorMessage &/*msg*/)
} }
void ThreadExecutor::reportInfo(const ErrorLogger::ErrorMessage &msg)
{
}
#endif #endif

View File

@ -44,6 +44,7 @@ public:
unsigned int check(); unsigned int check();
virtual void reportOut(const std::string &outmsg); virtual void reportOut(const std::string &outmsg);
virtual void reportErr(const ErrorLogger::ErrorMessage &msg); virtual void reportErr(const ErrorLogger::ErrorMessage &msg);
virtual void reportInfo(const ErrorLogger::ErrorMessage &msg);
/** /**
* @brief Add content to a file, to be used in unit testing. * @brief Add content to a file, to be used in unit testing.

View File

@ -209,8 +209,7 @@ unsigned int CppCheck::processFile(const std::string& filename)
"toomanyconfigs", "toomanyconfigs",
false); false);
reportErr(errmsg); reportInfo(errmsg);
break; break;
} }
@ -512,6 +511,11 @@ void CppCheck::reportProgress(const std::string &filename, const char stage[], c
_errorLogger.reportProgress(filename, stage, value); _errorLogger.reportProgress(filename, stage, value);
} }
void CppCheck::reportInfo(const ErrorLogger::ErrorMessage &msg)
{
_errorLogger.reportInfo(msg);
}
void CppCheck::reportStatus(unsigned int /*fileindex*/, unsigned int /*filecount*/, size_t /*sizedone*/, size_t /*sizetotal*/) void CppCheck::reportStatus(unsigned int /*fileindex*/, unsigned int /*filecount*/, size_t /*sizedone*/, size_t /*sizetotal*/)
{ {

View File

@ -175,6 +175,11 @@ private:
void reportProgress(const std::string &filename, const char stage[], const unsigned int value); void reportProgress(const std::string &filename, const char stage[], const unsigned int value);
/**
* Output information messages.
*/
virtual void reportInfo(const ErrorLogger::ErrorMessage &msg);
CheckUnusedFunctions _checkUnusedFunctions; CheckUnusedFunctions _checkUnusedFunctions;
ErrorLogger &_errorLogger; ErrorLogger &_errorLogger;

View File

@ -266,8 +266,7 @@ public:
* Information about found errors and warnings is directed * Information about found errors and warnings is directed
* here. Override this to receive the errormessages. * here. Override this to receive the errormessages.
* *
* @param msg Location and other information about the found. * @param msg Location and other information about the found error.
* error
*/ */
virtual void reportErr(const ErrorLogger::ErrorMessage &msg) = 0; virtual void reportErr(const ErrorLogger::ErrorMessage &msg) = 0;
@ -283,6 +282,12 @@ public:
(void)value; (void)value;
} }
/**
* Output information messages.
* @param msg Location and other information about the found error.
*/
virtual void reportInfo(const ErrorLogger::ErrorMessage &msg) = 0;
/** /**
* Report list of unmatched suppressions * Report list of unmatched suppressions
* @param unmatched list of unmatched suppressions (from Settings::Suppressions::getUnmatched(Local|Global)Suppressions) * @param unmatched list of unmatched suppressions (from Settings::Suppressions::getUnmatched(Local|Global)Suppressions)

View File

@ -2100,7 +2100,7 @@ void Preprocessor::missingInclude(const std::string &filename, unsigned int line
const std::string id = userheader ? "missingInclude" : "debug"; const std::string id = userheader ? "missingInclude" : "debug";
ErrorLogger::ErrorMessage errmsg(locationList, severity, "Include file: \"" + header + "\" not found.", id, false); ErrorLogger::ErrorMessage errmsg(locationList, severity, "Include file: \"" + header + "\" not found.", id, false);
errmsg.file0 = file0; errmsg.file0 = file0;
_errorLogger->reportErr(errmsg); errorLogger->reportInfo(errmsg);
} }
/** /**