-
Notifications
You must be signed in to change notification settings - Fork 1.5k
CppcheckExecutor: use dedicated ErrorLogger for printing error messages XML #4985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,8 +67,23 @@ | |
| #include <windows.h> | ||
| #endif | ||
|
|
||
| // TODO: do not directly write to stdout | ||
| class XMLErrorMessagesLogger : public ErrorLogger | ||
| { | ||
| void reportOut(const std::string & outmsg, Color /*c*/ = Color::Reset) override | ||
| { | ||
| std::cout << outmsg << std::endl; | ||
| } | ||
|
|
||
| void reportErr(const ErrorMessage &msg) override | ||
| { | ||
| reportOut(msg.toXML()); | ||
| } | ||
|
|
||
| void reportProgress(const std::string & /*filename*/, const char /*stage*/[], const std::size_t /*value*/) override | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @danmar I do see it being used as an cancellation callback but as that callback is hit very rarely that will probably not work as expected. That could be implemented via the Sorry for having yet another off-topic discussion in a PR (we should really enable the discussions on the repo).
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea was that if analysis of a file takes minutes.. it will be helpful for the user to see that there is progress and that we haven't hanged. It was mostly for the GUI. Unfortunately it's not used in the GUI as far as I know it's not trivial to add it properly (technically it's easy but ui-wise not so easy). Technically we could add labels and progress bars for each thread in the mainwindow but it will waste precious space...
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the command line a message is written every ~ 10 seconds. But the idea was to update the progress in the GUI more often maybe every seconds or so..
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #5269. |
||
| {} | ||
| }; | ||
|
|
||
| // TODO: do not directly write to stdout | ||
|
|
||
| /*static*/ FILE* CppCheckExecutor::mExceptionOutput = stdout; | ||
|
|
||
|
|
@@ -97,9 +112,9 @@ bool CppCheckExecutor::parseFromArgs(Settings &settings, int argc, const char* c | |
| } | ||
|
|
||
| if (parser.getShowErrorMessages()) { | ||
| mShowAllErrors = true; | ||
| XMLErrorMessagesLogger xmlLogger; | ||
| std::cout << ErrorMessage::getXMLHeader(settings.cppcheckCfgProductName); | ||
| CppCheck::getErrorMessages(*this); | ||
| CppCheck::getErrorMessages(xmlLogger); | ||
| std::cout << ErrorMessage::getXMLFooter() << std::endl; | ||
| } | ||
|
|
||
|
|
@@ -409,11 +424,6 @@ void CppCheckExecutor::reportProgress(const std::string &filename, const char st | |
|
|
||
| void CppCheckExecutor::reportErr(const ErrorMessage &msg) | ||
| { | ||
| if (mShowAllErrors) { | ||
| reportOut(msg.toXML()); | ||
| return; | ||
| } | ||
|
|
||
| assert(mSettings != nullptr); | ||
|
|
||
| // Alert only about unique errors | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have the feeling we want to write errors to std::cerr
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just for printing the XML and moves the previous code which did the same:
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this code only meant to be used if
--errorlistis used? I assumed this errorlogger would be used to output warnings during normal analysis also.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
It should probably be moved somewhere else. I have a refactoring of the
CmdLineParserwhich moves some things around which might help with this.This PR is just about cleaning up the
ErrorLoggerimplementation inCppcheckExecutora bit.