Skip to content
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

change SKIN_WARNING to show the skin file:line first, then c++ context #12253

Merged
merged 2 commits into from
Dec 9, 2023

Conversation

ronso0
Copy link
Member

@ronso0 ronso0 commented Nov 4, 2023

The failing skin xml line can now be spotted much easier, especially if your source directory path is rather long.

before:

warning [Main] /long/path/to/mixxx-source-directory/src/widget/whotcuebutton.cpp:36 SKIN ERROR at skin:../LateNight/controls/button_hotcue.xml:10 <HotcueButton>: Hotcue value invalid

now:

warning [Main] Skin parsing failed at skin:../LateNight/controls/button_hotcue.xml:10 <HotcueButton>: Hotcue value invalid at /long/path/to/mixxx-source-directory/src/widget/whotcuebutton.cpp:36

The xml path and the error message are meaningful already, so maybe we can omit /path/to/mixxx-source-file/:123 altogether. Just my impression, I didn't check all usages.

@JoergAtGithub
Copy link
Member

JoergAtGithub commented Nov 5, 2023

I tested this an works as expected, apart that I get absolute path for the XML file (independent of the change in this PR).

warning [Main] LegacySkinParser::loadTemplate - setContent failed see "C:/Users/Joerg.WORLDWARTWEB/source/repos/JoergAtGithub/mixxx/res/skins/LateNight/mixer.xml" line: 27 column: 24
warning [Main] LegacySkinParser::loadTemplate - message: "error occurred while parsing element"
warning [Main] SKIN ERROR at C:/Users/Joerg.WORLDWARTWEB/source/repos/JoergAtGithub/mixxx/res/skins/LateNight/skin.xml:453 <Template>: Template instantiation for template failed: skin:../LateNight/mixer.xml | C:\Users\Joerg.WORLDWARTWEB\source\repos\JoergAtGithub\mixxx\src\skin\legacy\legacyskinparser.cpp:1760

Why do we print this as warning and use the words SKIN ERROR? This does not match to me.

@ronso0
Copy link
Member Author

ronso0 commented Nov 5, 2023

Well, it's not fatal for the app, it's just SKIN PARSING ERROR to be exact.
Any idea how to improve it? Shall we rename it?

@JoergAtGithub
Copy link
Member

Maybe warning [Main] Skin parsing failed at:

@ronso0
Copy link
Member Author

ronso0 commented Nov 5, 2023

Makes sense. I'll check if SKIN_WARNING is indeed only used for parsing errors.

@ronso0
Copy link
Member Author

ronso0 commented Nov 5, 2023

It is. I changed it to Skin parsing failed at
And amended some minor fixes to the previous commit.

@daschuer
Copy link
Member

daschuer commented Nov 6, 2023

Maybe warning [Main] Skin parsing failed at:

Or even shorter:

warning [Main] parsing:

@@ -1049,7 +1067,7 @@ QWidget* LegacySkinParser::parseText(const QDomElement& node) {
QString group = lookupNodeGroup(node);
BaseTrackPlayer* pPlayer = m_pPlayerManager->getPlayer(group);
if (!pPlayer) {
SKIN_WARNING(node, *m_pContext) << "No player found for group:" << group;
SKIN_WARNING(node, *m_pContext, QStringLiteral("No player found for group:").arg(group));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the %1 missing.
I am afraid the arg() version is more expensive than the original.
I have an idea to keep the stream type working. See my other comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I understand the argument to aim for best possible performance and appreciate the effort you put into the skinWarning class example below, I do wonder if this fully applies here. It's a warning after all indicating the GUI won't be functional as expected, and if a significant amount of warnings is printed this small performance regression is the least we should be worried about IMHO.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not apply here, sure. The mandatory issue is only the missing %1

file,
QString::number(line))
.toUtf8()
.constData();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To allow keep using the stream operators you may inherit from QDebug()
(Not sure if it is worth the effort)

Not yet working idea:

class SkinWarning : public QDebug {
  public:
    SkinWarning(const char* file,
        const int line,
        const QDomNode& node,
        const QString& message) 
            : QDebug(QtWarningMsg) {
        *this << "Skin parsing failed at" << QString(m_xmlPath,) + QChar(':') + QString::number(node.lineNumber());
    }

    ~SkinWarning() {
        *this << QString(m_file) + QChar(':') + QString::number(m_line);
    }
  private:
      const char* m_file,
      const int m_line,
};
```

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! Didn't think about creating a dedicated class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are your plans with this PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try your suggestions, and if it gives my too much headaches I'd rather merge this as is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aaah, oooh, FILE and LINE are pre-processor macros. A little less magic now.

Anyway, I gave it a shot but it doesn't work as expected, or I just didn't fully understand how you plan to implement. I assumed you aimed to leave all SKIN_WARNING() calls unchanged.
https://github.com/ronso0/mixxx/pull/new/skin-warning-class incl. one commit with hotcue 0 to trigger a warning.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are motivated and manage to fix it, fine. I can re-apply the individual tweaks on top of your branch.
Otherwise let's merge this as is, maybe drop a comment so someone can try again later.

<< QString::fromStdString(attribute.value());
SKIN_WARNING(skinDocument,
*m_pContext,
QStringLiteral("Error reading double value from skin attribute: %1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
QStringLiteral("Error reading double value from skin attribute: %1")
QStringLiteral("Failed reading double value from skin attribute: %1")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@JoergAtGithub
Copy link
Member

LGTM! Thank you!

@JoergAtGithub JoergAtGithub merged commit 69159c5 into mixxxdj:2.4 Dec 9, 2023
12 checks passed
@ronso0 ronso0 deleted the skin-error-logging branch December 11, 2023 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make skin parser warnings less verbose, shorten/omit file path
3 participants