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
Musicxml import logging #3330
Merged
Merged
Musicxml import logging #3330
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
//============================================================================= | ||
// MuseScore | ||
// Music Composition & Notation | ||
// | ||
// Copyright (C) 2017 Werner Schweer and others | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License version 2 | ||
// as published by the Free Software Foundation and appearing in | ||
// the file LICENCE.GPL | ||
//============================================================================= | ||
|
||
#include "importmxmllogger.h" | ||
|
||
namespace Ms { | ||
|
||
//--------------------------------------------------------- | ||
// xmlLocation | ||
//--------------------------------------------------------- | ||
|
||
static QString xmlLocation(const QXmlStreamReader* const xmlreader) | ||
{ | ||
QString loc; | ||
if (xmlreader) { | ||
loc = QString(" at line %1 col %2").arg(xmlreader->lineNumber()).arg(xmlreader->columnNumber()); | ||
} | ||
return loc; | ||
|
||
} | ||
|
||
//--------------------------------------------------------- | ||
// logDebugTrace | ||
//--------------------------------------------------------- | ||
|
||
static void log(MxmlLogger::Level level, const QString& text, const QXmlStreamReader* const xmlreader) | ||
{ | ||
QString str; | ||
switch (level) { | ||
case MxmlLogger::Level::TRACE: str = "Trace"; break; | ||
case MxmlLogger::Level::INFO: str = "Info"; break; | ||
case MxmlLogger::Level::ERROR: str = "Error"; break; | ||
default: str = "Unknown"; break; | ||
} | ||
|
||
str += xmlLocation(xmlreader); | ||
str += ": "; | ||
str += text; | ||
|
||
qDebug("%s", qPrintable(str)); | ||
} | ||
|
||
//--------------------------------------------------------- | ||
// logDebugTrace | ||
//--------------------------------------------------------- | ||
|
||
/** | ||
Log debug (function) trace. | ||
*/ | ||
|
||
void MxmlLogger::logDebugTrace(const QString& trace, const QXmlStreamReader* const xmlreader) | ||
{ | ||
if (_level <= Level::TRACE) { | ||
log(Level::TRACE, trace, xmlreader); | ||
} | ||
} | ||
|
||
//--------------------------------------------------------- | ||
// logDebugInfo | ||
//--------------------------------------------------------- | ||
|
||
/** | ||
Log debug \a info (non-fatal events relevant for debugging). | ||
*/ | ||
|
||
void MxmlLogger::logDebugInfo(const QString& info, const QXmlStreamReader* const xmlreader) | ||
{ | ||
if (_level <= Level::INFO) { | ||
log(Level::INFO, info, xmlreader); | ||
} | ||
} | ||
|
||
//--------------------------------------------------------- | ||
// logError | ||
//--------------------------------------------------------- | ||
|
||
/** | ||
Log \a error (possibly non-fatal but to be reported to the user anyway). | ||
*/ | ||
|
||
void MxmlLogger::logError(const QString& error, const QXmlStreamReader* const xmlreader) | ||
{ | ||
if (_level <= Level::ERROR) { | ||
log(Level::ERROR, error, xmlreader); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//============================================================================= | ||
// MuseScore | ||
// Music Composition & Notation | ||
// | ||
// Copyright (C) 2017 Werner Schweer and others | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License version 2 | ||
// as published by the Free Software Foundation and appearing in | ||
// the file LICENCE.GPL | ||
//============================================================================= | ||
|
||
#ifndef __IMPORTMXMLLOGGER_H__ | ||
#define __IMPORTMXMLLOGGER_H__ | ||
|
||
class QXmlStreamReader; | ||
|
||
namespace Ms { | ||
|
||
class MxmlLogger { | ||
public: | ||
enum class Level : char { | ||
TRACE, INFO, ERROR | ||
}; | ||
MxmlLogger() {} | ||
void logDebugTrace(const QString& trace, const QXmlStreamReader* const xmlreader = 0); | ||
void logDebugInfo(const QString& info, const QXmlStreamReader* const xmlreader = 0); | ||
void logError(const QString& error, const QXmlStreamReader* const xmlreader = 0); | ||
void setLoggingLevel(const Level level) { _level = level; } | ||
private: | ||
Level _level = Level::INFO; | ||
}; | ||
|
||
} // namespace Ms | ||
|
||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
INFO and ERROR conflicts with something in a Windows specific header, so it doesn't build there, renaming to XINFO and XERROR fixes the build problem