#include "log.h" #include #include bool SQL_DEBUG = false; QString SQL_DEBUG_FILTER = ""; void setSqlLoggingEnabled(bool enabled) { SQL_DEBUG = enabled; } void setSqlLoggingFilter(const QString& filter) { SQL_DEBUG_FILTER = filter; } void logSql(Db* db, const QString& str, const QHash& args, Db::Flags flags) { if (!SQL_DEBUG) return; if (!SQL_DEBUG_FILTER.isEmpty() && SQL_DEBUG_FILTER != db->getName()) return; qDebug() << QString("SQL %1> %2").arg(db->getName()).arg(str) << "(flags:" << Db::flagsToString(flags) << ")"; QHashIterator it(args); while (it.hasNext()) { it.next(); qDebug() << " SQL arg>" << it.key() << "=" << it.value(); } } void logSql(Db* db, const QString& str, const QList& args, Db::Flags flags) { if (!SQL_DEBUG) return; if (!SQL_DEBUG_FILTER.isEmpty() && SQL_DEBUG_FILTER != db->getName()) return; qDebug() << QString("SQL %1> %2").arg(db->getName()).arg(str) << "(flags:" << Db::flagsToString(flags) << ")"; int i = 0; foreach (const QVariant& arg, args) qDebug() << " SQL arg>" << i++ << "=" << arg; }