Improve logging changes when applying changes in JavaScript
* Don't log non-printable characters * Make it clear when an explicitly overridden field value is identical to the initial value
This commit is contained in:
parent
d248c63279
commit
44d0ac21c2
|
@ -373,6 +373,17 @@ QString TagObject::propertyNameForField(TagParser::KnownField field)
|
||||||
return reverseMapping.value(field, QString());
|
return reverseMapping.value(field, QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string TagObject::printJsValue(const QJSValue &value)
|
||||||
|
{
|
||||||
|
const auto str = value.toString();
|
||||||
|
for (const auto c : str) {
|
||||||
|
if (!c.isPrint()) {
|
||||||
|
return "[binary]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return str.toStdString();
|
||||||
|
}
|
||||||
|
|
||||||
QJSValue &TagObject::fields()
|
QJSValue &TagObject::fields()
|
||||||
{
|
{
|
||||||
if (!m_fields.isUndefined()) {
|
if (!m_fields.isUndefined()) {
|
||||||
|
@ -446,11 +457,14 @@ void TagObject::applyChanges()
|
||||||
m_diag.emplace_back(TagParser::DiagLevel::Debug,
|
m_diag.emplace_back(TagParser::DiagLevel::Debug,
|
||||||
value.isNull()
|
value.isNull()
|
||||||
? CppUtilities::argsToString(" - delete ", propertyName.toStdString(), '[', i, ']')
|
? CppUtilities::argsToString(" - delete ", propertyName.toStdString(), '[', i, ']')
|
||||||
: (tagValueObj->initialContent().isUndefined() ? CppUtilities::argsToString(
|
: (tagValueObj->initialContent().isUndefined()
|
||||||
" - set ", propertyName.toStdString(), '[', i, "] to '", tagValueObj->content().toString().toStdString(), '\'')
|
? CppUtilities::argsToString(
|
||||||
: CppUtilities::argsToString(" - change ", propertyName.toStdString(), '[', i,
|
" - set ", propertyName.toStdString(), '[', i, "] to '", printJsValue(tagValueObj->content()), '\'')
|
||||||
"] from '", tagValueObj->initialContent().toString().toStdString(), "' to '",
|
: ((tagValueObj->content().equals(tagValueObj->initialContent()))
|
||||||
tagValueObj->content().toString().toStdString(), '\'')),
|
? CppUtilities::argsToString(" - set ", propertyName.toStdString(), '[', i, "] to '",
|
||||||
|
printJsValue(tagValueObj->content()), "\' (no change)")
|
||||||
|
: CppUtilities::argsToString(" - change ", propertyName.toStdString(), '[', i, "] from '",
|
||||||
|
printJsValue(tagValueObj->initialContent()), "' to '", printJsValue(tagValueObj->content()), '\''))),
|
||||||
std::string());
|
std::string());
|
||||||
}
|
}
|
||||||
m_tag.setValues(field, values);
|
m_tag.setValues(field, values);
|
||||||
|
|
|
@ -164,6 +164,7 @@ public Q_SLOTS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QString propertyNameForField(TagParser::KnownField field);
|
static QString propertyNameForField(TagParser::KnownField field);
|
||||||
|
std::string printJsValue(const QJSValue &value);
|
||||||
|
|
||||||
TagParser::Tag &m_tag;
|
TagParser::Tag &m_tag;
|
||||||
TagParser::Diagnostics &m_diag;
|
TagParser::Diagnostics &m_diag;
|
||||||
|
|
Loading…
Reference in New Issue