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());
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
if (!m_fields.isUndefined()) {
|
||||
|
@ -446,11 +457,14 @@ void TagObject::applyChanges()
|
|||
m_diag.emplace_back(TagParser::DiagLevel::Debug,
|
||||
value.isNull()
|
||||
? CppUtilities::argsToString(" - delete ", propertyName.toStdString(), '[', i, ']')
|
||||
: (tagValueObj->initialContent().isUndefined() ? CppUtilities::argsToString(
|
||||
" - set ", propertyName.toStdString(), '[', i, "] to '", tagValueObj->content().toString().toStdString(), '\'')
|
||||
: CppUtilities::argsToString(" - change ", propertyName.toStdString(), '[', i,
|
||||
"] from '", tagValueObj->initialContent().toString().toStdString(), "' to '",
|
||||
tagValueObj->content().toString().toStdString(), '\'')),
|
||||
: (tagValueObj->initialContent().isUndefined()
|
||||
? CppUtilities::argsToString(
|
||||
" - set ", propertyName.toStdString(), '[', i, "] to '", printJsValue(tagValueObj->content()), '\'')
|
||||
: ((tagValueObj->content().equals(tagValueObj->initialContent()))
|
||||
? 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());
|
||||
}
|
||||
m_tag.setValues(field, values);
|
||||
|
|
|
@ -164,6 +164,7 @@ public Q_SLOTS:
|
|||
|
||||
private:
|
||||
static QString propertyNameForField(TagParser::KnownField field);
|
||||
std::string printJsValue(const QJSValue &value);
|
||||
|
||||
TagParser::Tag &m_tag;
|
||||
TagParser::Diagnostics &m_diag;
|
||||
|
|
Loading…
Reference in New Issue