refs #646 Log messages when saving and loading data cache values.

This commit is contained in:
Mathew Sutcliffe
2016-05-18 17:50:29 +01:00
parent 5a43ff8d20
commit 05b5971caf
3 changed files with 15 additions and 4 deletions

View File

@@ -234,7 +234,9 @@ namespace BlackMisc
if (! lock) { return; }
m_cache->m_revision.writeNewRevision(baseline.toTimestampMap());
m_cache->saveToFiles(persistentStore(), values);
auto msg = m_cache->saveToFiles(persistentStore(), values);
msg.setCategories(this);
CLogMessage::preformatted(msg);
applyDeferredChanges(); // apply changes which we grabbed at the last minute above
}
@@ -245,7 +247,9 @@ namespace BlackMisc
if (lock && m_cache->m_revision.isPendingRead())
{
CValueCachePacket newValues;
m_cache->loadFromFiles(persistentStore(), m_cache->m_revision.keysWithNewerTimestamps(), baseline.toVariantMap(), newValues);
auto msg = m_cache->loadFromFiles(persistentStore(), m_cache->m_revision.keysWithNewerTimestamps(), baseline.toVariantMap(), newValues);
msg.setCategories(this);
CLogMessage::preformatted(msg);
m_deferredChanges.insert(newValues);
}

View File

@@ -192,6 +192,13 @@ namespace BlackMisc
//! Implicit conversion to any container of value_type which supports push_back. This will copy elements.
template <class T, class = std::enable_if_t<std::is_convertible<value_type, typename T::value_type>::value>>
operator T() const
{
return to<T>();
}
//! Explicit conversion to any container of value_type which supports push_back. This will copy elements.
template <class T>
T to() const
{
T container;
std::copy(begin(), end(), std::back_inserter(container));

View File

@@ -304,7 +304,7 @@ namespace BlackMisc
}
}
return CStatusMessage(this, CStatusMessage::SeverityInfo,
QString("Written %1 files for value cache in %2").arg(namespaces.size()).arg(dir));
QString("Written %1 to value cache in %2").arg(values.keys().to<QStringList>().join(",")).arg(dir));
}
CStatusMessage CValueCache::loadFromFiles(const QString &dir)
@@ -347,7 +347,7 @@ namespace BlackMisc
o_values.insert(temp, QFileInfo(file).lastModified().toMSecsSinceEpoch());
}
return CStatusMessage(this, CStatusMessage::SeverityInfo,
QString("Loaded value cache from %1 files in %2").arg(entries.size()).arg(dir));
QString("Loaded cache values %1 from %2").arg(o_values.keys().to<QStringList>().join(",")).arg(dir));
}
void CValueCache::markAllAsSaved(const QString &keyPrefix)