mirror of
https://github.com/QuasarApp/Heart.git
synced 2025-04-26 01:34:37 +00:00
fix warnings
This commit is contained in:
parent
0629079687
commit
21d07c2b30
@ -95,7 +95,7 @@ bool BigDataParser::newPackage(const QSharedPointer<PKG::BigDataHeader> &header,
|
||||
request.setCurrentPart(0);
|
||||
request.setPackageId(header->packageId());
|
||||
|
||||
QuasarAppUtils::Params::log("Receive BigData Header:" + header->toString());
|
||||
qDebug() << "Receive BigData Header:" << header->toString();
|
||||
|
||||
return node()->sendData(&request, sender, &hdr);
|
||||
}
|
||||
@ -112,10 +112,7 @@ bool BigDataParser::processPart(const QSharedPointer<PKG::BigDataPart> &part,
|
||||
|
||||
auto& localPool = _pool[part->packageId()];
|
||||
|
||||
QuasarAppUtils::Params::log(QString("Process Part of %0: part %1/%2").
|
||||
arg(part->packageId()).
|
||||
arg(part->getPakckageNumber()).
|
||||
arg(localPool.chaindata.size() - 1));
|
||||
qDebug () << "Process Part of" << part->packageId() << ": part" << part->getPakckageNumber() << "/" << localPool.chaindata.size() - 1;
|
||||
|
||||
localPool.chaindata[part->getPakckageNumber()] = part;
|
||||
|
||||
@ -167,7 +164,7 @@ bool BigDataParser::processRequest(const QSharedPointer<PKG::BigDataRequest> &re
|
||||
unsigned int id = request->packageId();
|
||||
|
||||
if (!_pool.contains(id)) {
|
||||
QuasarAppUtils::Params::log("requested data is missing!");
|
||||
qDebug() << "requested data is missing!";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ bool QH::DataSender::sendPackagePrivate(QByteArray array, void *target) const {
|
||||
auto ptr = static_cast<QAbstractSocket*>(target);
|
||||
|
||||
if (!(ptr && ptr->isValid() && ptr->isWritable())) {
|
||||
QuasarAppUtils::Params::log("Send raw data error. Socket is invalid", QuasarAppUtils::Error);
|
||||
qCritical() << "Send raw data error. Socket is invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -37,13 +37,12 @@ bool QH::DataSender::sendPackagePrivate(QByteArray array, void *target) const {
|
||||
}
|
||||
|
||||
if (!ptr->flush()) {
|
||||
QuasarAppUtils::Params::log("Send raw data error. data not flushed", QuasarAppUtils::Error);
|
||||
|
||||
qCritical() << "Send raw data error. data not flushed";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (array.size() != wrote) {
|
||||
QuasarAppUtils::Params::log("not writed data to socket", QuasarAppUtils::Error);
|
||||
qCritical() << "Send raw data error. not all data writed";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -116,11 +116,10 @@ bool AbstractNode::run(const QString &addres, unsigned short port) {
|
||||
}
|
||||
|
||||
if (!listen(adr)) {
|
||||
QuasarAppUtils::Params::log("Run fail " + this->errorString(),
|
||||
QuasarAppUtils::Error);
|
||||
|
||||
QuasarAppUtils::Params::log("Address:: " + adr.toString(),
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Run fail " << this->errorString();
|
||||
qCritical() << "Address:: " << adr.toString();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -256,9 +255,9 @@ bool AbstractNode::addNode(const QString &domain, unsigned short port,
|
||||
QHostInfo::lookupHost(domain, [this, port, domain, action, status](QHostInfo info) {
|
||||
|
||||
if (info.error() != QHostInfo::NoError) {
|
||||
QuasarAppUtils::Params::log("The domain name :" + domain +
|
||||
" has error: " + info.errorString(),
|
||||
QuasarAppUtils::Error);
|
||||
|
||||
qCritical() << "The domain name :" + domain +
|
||||
" has error: " + info.errorString();
|
||||
addNodeFailed(AddNodeError::HostNotFound);
|
||||
return;
|
||||
}
|
||||
@ -266,9 +265,8 @@ bool AbstractNode::addNode(const QString &domain, unsigned short port,
|
||||
auto addresses = info.addresses();
|
||||
|
||||
if (addresses.size() > 1) {
|
||||
QuasarAppUtils::Params::log("The domain name :" + domain +
|
||||
" has more 1 ip addresses.",
|
||||
QuasarAppUtils::Warning);
|
||||
qWarning() << "The domain name :" + domain +
|
||||
" has more 1 ip addresses.";
|
||||
}
|
||||
|
||||
if (action) {
|
||||
@ -571,14 +569,13 @@ bool AbstractNode::sendPackage(const Package &pkg, QAbstractSocket *target) cons
|
||||
}
|
||||
|
||||
if (!target || !target->isValid()) {
|
||||
QuasarAppUtils::Params::log("destination server not valid!",
|
||||
QuasarAppUtils::Error);
|
||||
|
||||
qCritical() << "Destination server not valid!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!target->waitForConnected()) {
|
||||
QuasarAppUtils::Params::log("no connected to server! " + target->errorString(),
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "no connected to server! " + target->errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -596,7 +593,7 @@ unsigned int AbstractNode::sendData(const PKG::AbstractData *resp,
|
||||
const Header *req) {
|
||||
|
||||
if (!node) {
|
||||
QuasarAppUtils::Params::log("Response not sent because client == null");
|
||||
qDebug() << "Response not sent because client == null";
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -625,15 +622,12 @@ unsigned int AbstractNode::sendData(const PKG::AbstractData *resp,
|
||||
|
||||
return BIG_DATA_HASH_ID;
|
||||
}
|
||||
|
||||
QuasarAppUtils::Params::log("Response not sent because dont create package from object",
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Response not sent because dont create package from object";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!sendPackage(pkg, node->sct())) {
|
||||
QuasarAppUtils::Params::log("Response not sent!",
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Response not sent!";
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -645,13 +639,13 @@ void AbstractNode::badRequest(const HostAddress &address, const Header &req,
|
||||
|
||||
if (!changeTrust(address, diff)) {
|
||||
|
||||
QuasarAppUtils::Params::log("Bad request detected, bud response command not sent!"
|
||||
" because trust not changed",
|
||||
QuasarAppUtils::Error);
|
||||
|
||||
QuasarAppUtils::Params::log("SECURITY LOG: Force block the " + address.toString() +
|
||||
" because trust defined",
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Bad request detected, bud response command not sent!"
|
||||
" because trust not changed";
|
||||
|
||||
|
||||
qCritical() << "SECURITY LOG: Force block the " + address.toString() +
|
||||
" because trust defined";
|
||||
|
||||
ban(address);
|
||||
|
||||
@ -665,9 +659,7 @@ void AbstractNode::badRequest(const HostAddress &address, const Header &req,
|
||||
return;
|
||||
}
|
||||
|
||||
QuasarAppUtils::Params::log("Bad request sendet to adderess: " +
|
||||
address.toString(),
|
||||
QuasarAppUtils::Info);
|
||||
qInfo() << "Bad request sendet to adderess: " + address.toString();
|
||||
|
||||
if (fCloseConnectionAfterBadRequest()) {
|
||||
removeNode(node);
|
||||
@ -776,8 +768,7 @@ void AbstractNode::incomingConnection(qintptr handle) {
|
||||
socket->setSocketDescriptor(handle);
|
||||
|
||||
if (isBanned(getInfoPtr(HostAddress{socket->peerAddress(), socket->peerPort()}))) {
|
||||
QuasarAppUtils::Params::log("Income connection from banned address",
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Income connection from banned address";
|
||||
|
||||
delete socket;
|
||||
return false;
|
||||
@ -785,8 +776,7 @@ void AbstractNode::incomingConnection(qintptr handle) {
|
||||
|
||||
if (!registerSocket(socket)) {
|
||||
|
||||
QuasarAppUtils::Params::log("Failed to register new socket",
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Failed to register new socket";
|
||||
|
||||
delete socket;
|
||||
return false;
|
||||
@ -903,8 +893,7 @@ void AbstractNode::avelableBytes(AbstractNodeInfo *sender) {
|
||||
pkg.reset();
|
||||
hdrArray.clear();
|
||||
} else if (static_cast<unsigned int>(pkg.data.size()) >= pkg.hdr.size) {
|
||||
QuasarAppUtils::Params::log("Invalid Package received." + pkg.toString(),
|
||||
QuasarAppUtils::Warning);
|
||||
qWarning() << "Invalid Package received." + pkg.toString();
|
||||
pkg.reset();
|
||||
hdrArray.clear();
|
||||
changeTrust(id, CRITICAL_ERROOR);
|
||||
@ -968,9 +957,9 @@ AbstractNode::prepareData(const Package &pkg,
|
||||
|
||||
auto value = _apiVersionParser->searchPackage(pkg.hdr.command, sender);
|
||||
if (!value) {
|
||||
QuasarAppUtils::Params::log("You try parse not registered package type."
|
||||
" Plese use the registerPackageType method befor parsing."
|
||||
" Example invoke registerPackageType<MyData>() into constructor of you client and server nodes.");
|
||||
qDebug() << "Package type not registered!"
|
||||
" Please use the registerPackageType method before parsing."
|
||||
" Example invoke registerPackageType<MyData>() into constructor of you client and server nodes.";
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@ -1003,21 +992,18 @@ void AbstractNode::addNodeFailed(AddNodeError error) {
|
||||
|
||||
switch (error) {
|
||||
case AddNodeError::HostNotFound: {
|
||||
QuasarAppUtils::Params::log("The remote host not found or dns server not responce.",
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "The remote host not found or dns server not responce.";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case AddNodeError::RegisterSocketFailed: {
|
||||
QuasarAppUtils::Params::log("The remote node is banned or serve is overload.",
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "The remote node is banned or serve is overload.";
|
||||
break;
|
||||
|
||||
}
|
||||
default: {
|
||||
QuasarAppUtils::Params::log("The unknown error ocurred.",
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "The unknown error ocurred.";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1072,7 +1058,7 @@ void AbstractNode::newWork(const Package &pkg, AbstractNodeInfo *sender,
|
||||
auto message = QString("Package not parsed! %0 \nresult: %1. \n%2").
|
||||
arg(pkg.toString(), iParser::pareseResultToString(parseResult), data->toString());
|
||||
|
||||
QuasarAppUtils::Params::log(message, QuasarAppUtils::Info);
|
||||
qInfo() << message;
|
||||
|
||||
if (parseResult == ParserResult::Error) {
|
||||
|
||||
@ -1093,7 +1079,7 @@ void AbstractNode::newWork(const Package &pkg, AbstractNodeInfo *sender,
|
||||
}
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
QuasarAppUtils::Params::log(_apiVersionParser->toString(), QuasarAppUtils::Info);
|
||||
qInfo() << _apiVersionParser->toString();
|
||||
#endif
|
||||
|
||||
return false;
|
||||
@ -1181,8 +1167,7 @@ void AbstractNode::nodeConfirmend(AbstractNodeInfo *node) {
|
||||
|
||||
void AbstractNode::nodeConnected(AbstractNodeInfo *node) {
|
||||
if (!_apiVersionParser->sendSupportedAPI(node)) {
|
||||
QuasarAppUtils::Params::log("Failed to sent version information to dist node",
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Failed to sent version information to dist node";
|
||||
}
|
||||
|
||||
auto &actions = _connectActions[NodeCoonectionStatus::Connected];
|
||||
@ -1201,9 +1186,7 @@ void AbstractNode::nodeErrorOccured(AbstractNodeInfo *nodeInfo,
|
||||
Q_UNUSED(errorCode)
|
||||
|
||||
QString message("Network error occured on the %0 node. Message: %1");
|
||||
QuasarAppUtils::Params::log(
|
||||
message.arg(nodeInfo->networkAddress().toString(), errorString),
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << message.arg(nodeInfo->networkAddress().toString(), errorString);
|
||||
|
||||
auto &actions = _connectActions[NodeCoonectionStatus::Connected];
|
||||
actions.remove(nodeInfo->networkAddress());
|
||||
|
@ -208,8 +208,7 @@ void AbstractNodeInfo::setTrust(int trust) {
|
||||
_trust = trust;
|
||||
|
||||
if (isBanned() && _sct) {
|
||||
QuasarAppUtils::Params::log(QString("The node %0 is banned!").
|
||||
arg(_sct->peerAddress().toString()));
|
||||
qDebug() << "The node" << _sct->peerAddress().toString() << "is banned!";
|
||||
|
||||
removeSocket();
|
||||
}
|
||||
|
@ -46,8 +46,7 @@ ParserResult APIVersionParser::parsePackage(const QSharedPointer<PKG::AbstractDa
|
||||
const auto parser = selectParser(pkg->cmd(), sender);
|
||||
|
||||
if (!parser) {
|
||||
QuasarAppUtils::Params::log(QString("Can't found requeried parser for versions"),
|
||||
QuasarAppUtils::Warning);
|
||||
qWarning () << "Can't found requeried parser for versions";
|
||||
return ParserResult::NotProcessed;
|
||||
}
|
||||
|
||||
@ -101,8 +100,7 @@ APIVersionParser::searchPackage(unsigned short cmd,
|
||||
|
||||
for (const auto& parser: parsers) {
|
||||
if (!parser) {
|
||||
QuasarAppUtils::Params::log(QString("Internal Error with selection parasers."),
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Internal Error with selection parasers.";
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -148,7 +146,7 @@ bool QH::APIVersionParser::commandsValidation(const QSharedPointer<iParser> &par
|
||||
arg(parser->parserId()).
|
||||
arg(parser->version());
|
||||
|
||||
QuasarAppUtils::Params::log(err, QuasarAppUtils::Error);
|
||||
qCritical() << err;
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -318,11 +316,7 @@ bool APIVersionParser::processAppVersion(const QSharedPointer<PKG::APIVersion> &
|
||||
if (!parser.contains(*parserKey)) {
|
||||
auto requiredApi = distVersion.value(*parserKey);
|
||||
|
||||
QuasarAppUtils::Params::log(QString("Can't found %0 parser for versions: %1-%2").
|
||||
arg(*parserKey).
|
||||
arg(requiredApi.min()).
|
||||
arg(requiredApi.max()),
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Can't found required parser for versions: " << *parserKey << requiredApi.min() << requiredApi.max();
|
||||
|
||||
unsigned short distMinVersion = sender->version().value(*parserKey).min();
|
||||
|
||||
|
@ -85,8 +85,7 @@ bool Async::asyncLauncher(const Async::Job &job, bool await, bool freaze) const
|
||||
|
||||
if (!thread()->isRunning()) {
|
||||
|
||||
QuasarAppUtils::Params::log("The work threand of the async object is not running",
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "The work threand of the async object is not running";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -52,13 +52,11 @@ bool DataBase::initSqlDb(QString DBparamsFile,
|
||||
}
|
||||
|
||||
if (!upgradeDataBase()) {
|
||||
QuasarAppUtils::Params::log("Failed to upgrade database",
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Failed to upgrade database";
|
||||
return false;
|
||||
}
|
||||
|
||||
QuasarAppUtils::Params::log(QString("Database loaded from: %0").arg(dbLocation()),
|
||||
QuasarAppUtils::Debug);
|
||||
qDebug() << "Database loaded from: " << dbLocation();
|
||||
|
||||
connect(_db, &ISqlDB::sigItemChanged,
|
||||
this, &DataBase::sigObjectChanged,
|
||||
@ -222,10 +220,9 @@ bool DataBase::upgradeDataBase() {
|
||||
|
||||
if (!fsupportUpgrade) {
|
||||
|
||||
QuasarAppUtils::Params::log("The data base of application do not support soft upgrade. "
|
||||
"Please remove database monyaly and restart application."
|
||||
"You can disable upgrade functions for this override the upgradeDataBase method. ",
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "The data base of application do not support soft upgrade. "
|
||||
"Please remove database monyaly and restart application."
|
||||
"You can disable upgrade functions for this override the upgradeDataBase method. ";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -243,20 +240,17 @@ bool DataBase::upgradeDataBase() {
|
||||
auto patches = patchesPack.value(currentVersion, {});
|
||||
|
||||
if (!patches.size()) {
|
||||
QuasarAppUtils::Params::log("Failed to " + message.arg("Unknown", "Required patch not found!"),
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Failed to " + message.arg("Unknown", "Required patch not found!");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto patch = patches.last();
|
||||
message = message.arg(patch.versionTo);
|
||||
|
||||
QuasarAppUtils::Params::log(message.arg("(Begin)"),
|
||||
QuasarAppUtils::Info);
|
||||
qInfo() << message.arg("(Begin)");
|
||||
|
||||
if (!patch.action(db())) {
|
||||
QuasarAppUtils::Params::log("Failed to " + message.arg("Patch finished with error code!"),
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Failed to " + message.arg("Patch finished with error code!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -311,8 +305,8 @@ bool DataBase::setDBAttribute(const QString& key, const QVariant& newValue) {
|
||||
"value", newValue, "name");
|
||||
|
||||
if (!_db->replaceObject(updateVersionRequest, true)) {
|
||||
QuasarAppUtils::Params::log(QString("Failed to update %0 attribute").arg(key),
|
||||
QuasarAppUtils::Error);
|
||||
|
||||
qCritical() << "Failed to update " << key << " attribute";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -26,10 +26,9 @@ QSharedPointer<DBObject> iObjectProvider::getObjectRaw(
|
||||
return nullptr;
|
||||
|
||||
if (list.size() > 1) {
|
||||
QuasarAppUtils::Params::log("getObject method returned more than one object,"
|
||||
" the first object was selected as the result,"
|
||||
" all the rest were lost.",
|
||||
QuasarAppUtils::Warning);
|
||||
qWarning() << "getObject method returned more than one object,"
|
||||
" the first object was selected as the result,"
|
||||
" all the rest were lost.";
|
||||
}
|
||||
|
||||
return list.first();
|
||||
|
@ -48,9 +48,9 @@ public:
|
||||
auto val = getObjectRaw(templateVal);
|
||||
auto result = val.template dynamicCast<TYPE>();
|
||||
if (!result && !val.isNull()) {
|
||||
QuasarAppUtils::Params::log("getObject method returned object with deffirent type of TYPE,"
|
||||
" check getAllObjects merhod",
|
||||
QuasarAppUtils::Error);
|
||||
|
||||
qCritical() << "getObject method returned object with deffirent type of TYPE,"
|
||||
" check getAllObjects merhod";
|
||||
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ void ISqlDB::globalUpdateDataBase(SqlDBCasheWriteMode mode) {
|
||||
});
|
||||
|
||||
if (!future.isValid()) {
|
||||
QuasarAppUtils::Params::log("Failde to start update database thread");
|
||||
qDebug() << "Failde to start update database thread";
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
@ -170,9 +170,7 @@ bool ISqlDB::getAllObjects(const DBObject &templateObject,
|
||||
|
||||
for (const auto &object: std::as_const(result)) {
|
||||
if (object->isCached() && !insertToCache(object)) {
|
||||
QuasarAppUtils::Params::log("Selected object from database can not be saved into database cache. " +
|
||||
object->toString(),
|
||||
QuasarAppUtils::Warning);
|
||||
qWarning() << "Selected object from database can not be saved into database cache. " + object->toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -337,10 +335,7 @@ void ISqlDB::globalUpdateDataBasePrivate(qint64 currentTime) {
|
||||
if (!obj || !obj->isValid()) {
|
||||
deleteFromCache(obj);
|
||||
|
||||
QuasarAppUtils::Params::log("writeUpdateItemIntoDB failed when"
|
||||
" db object is not valid! obj=" +
|
||||
obj->toString(),
|
||||
QuasarAppUtils::VerboseLvl::Error);
|
||||
qCritical() << "writeUpdateItemIntoDB failed when db object is not valid! obj=" << obj->toString();
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -360,25 +355,18 @@ void ISqlDB::globalUpdateDataBasePrivate(qint64 currentTime) {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
QuasarAppUtils::Params::log("The Object of the cache have wrong type " +
|
||||
obj->toString(),
|
||||
QuasarAppUtils::VerboseLvl::Warning);
|
||||
qWarning() << "The Object of the cache have wrong type " << obj->toString();
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!saveResult ) {
|
||||
QuasarAppUtils::Params::log("writeUpdateItemIntoDB failed when"
|
||||
" work globalUpdateDataRelease!!! obj=" +
|
||||
obj->toString(),
|
||||
QuasarAppUtils::VerboseLvl::Error);
|
||||
qCritical() << "writeUpdateItemIntoDB failed when work globalUpdateDataRelease!!! obj=" << obj->toString();
|
||||
}
|
||||
} else {
|
||||
|
||||
QuasarAppUtils::Params::log("writeUpdateItemIntoDB failed when"
|
||||
" db writer is npt inited! ",
|
||||
QuasarAppUtils::VerboseLvl::Error);
|
||||
qCritical() << "writeUpdateItemIntoDB failed when db writer is not inited!";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -63,8 +63,7 @@ PrepareResult DBObject::prepareInsertQuery(QSqlQuery &q, bool replace) const {
|
||||
DBVariantMap map = variantMap();
|
||||
|
||||
if (!map.size()) {
|
||||
QuasarAppUtils::Params::log("The variantMap method return an empty map.",
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "The variantMap method return an empty map.";
|
||||
|
||||
return PrepareResult::Fail;
|
||||
}
|
||||
@ -125,8 +124,7 @@ PrepareResult DBObject::prepareUpdateQuery(QSqlQuery &q) const {
|
||||
DBVariantMap map = variantMap();
|
||||
|
||||
if (!map.size()) {
|
||||
QuasarAppUtils::Params::log("The variantMap method return an empty map.",
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "The variantMap method return an empty map.";
|
||||
|
||||
return PrepareResult::Fail;
|
||||
}
|
||||
@ -134,8 +132,7 @@ PrepareResult DBObject::prepareUpdateQuery(QSqlQuery &q) const {
|
||||
auto [conditionQueryString, conditionBindingMap] = condition();
|
||||
|
||||
if (conditionQueryString.isEmpty()) {
|
||||
QuasarAppUtils::Params::log("The object soue not have condition for update object.",
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "The object soue not have condition for update object.";
|
||||
return PrepareResult::Fail;
|
||||
}
|
||||
|
||||
@ -158,9 +155,8 @@ PrepareResult DBObject::prepareUpdateQuery(QSqlQuery &q) const {
|
||||
}
|
||||
|
||||
if (tableUpdateValues.isEmpty()) {
|
||||
QuasarAppUtils::Params::log("Fail to generate condition for object: " + toString() +
|
||||
". The object do not have valid update fields.",
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Fail to generate condition for object: " + toString() +
|
||||
". The object do not have valid update fields.";
|
||||
return PrepareResult::Fail;
|
||||
}
|
||||
|
||||
@ -179,11 +175,9 @@ PrepareResult DBObject::prepareUpdateQuery(QSqlQuery &q) const {
|
||||
for (auto it = conditionBindingMap.begin(); it != conditionBindingMap.end(); ++it) {
|
||||
#ifdef QT_DEBUG
|
||||
if (bool(map.value(it.key()).type & MemberType::Update)) {
|
||||
QuasarAppUtils::Params::log(QString("Bad object configuration: "
|
||||
"The %0 field using in the condition and has MemberType::Update configuration."
|
||||
" All condition fields should not use the MemberType::Update. \n %1").
|
||||
arg(it.key(), toString()),
|
||||
QuasarAppUtils::Warning);
|
||||
qWarning() << "Bad object configuration: "
|
||||
"The " << it.key() << " field using in the condition and has MemberType::Update configuration."
|
||||
" All condition fields should not use the MemberType::Update. \n" << toString();
|
||||
}
|
||||
#endif
|
||||
q.bindValue(it.key(), it.value());
|
||||
@ -218,10 +212,8 @@ std::pair<QString, QMap<QString, QVariant>> DBObject::condition() const {
|
||||
{{QString(":%0").arg(primaryKey()), {primaryVal}}}};
|
||||
}
|
||||
|
||||
|
||||
QuasarAppUtils::Params::log("Fail to generate condition for object: " + toString() +
|
||||
". Object do not have valid unique fields or valid database address.",
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Fail to generate condition for object: " + toString() +
|
||||
". Object do not have valid unique fields or valid database address.";
|
||||
|
||||
|
||||
return {};
|
||||
@ -249,18 +241,17 @@ QString DBObject::toString() const {
|
||||
}
|
||||
|
||||
QDataStream &DBObject::fromStream(QDataStream &stream) {
|
||||
QuasarAppUtils::Params::log("This object not support stream operator."
|
||||
" Please Override the fromStream method for this object. " + toString(),
|
||||
QuasarAppUtils::Warning);
|
||||
|
||||
qWarning() << "This object not support stream operator."
|
||||
" Please Override the fromStream method for this object. " + toString();
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
QDataStream &DBObject::toStream(QDataStream &stream) const {
|
||||
|
||||
QuasarAppUtils::Params::log("This object not support stream operator."
|
||||
" Please Override the toStream method for this object. " + toString(),
|
||||
QuasarAppUtils::Warning);
|
||||
qWarning() << "This object not support stream operator."
|
||||
" Please Override the toStream method for this object. " + toString();
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
@ -38,8 +38,7 @@ PrepareResult SetSingleValue::prepareUpdateQuery(QSqlQuery &q) const {
|
||||
|
||||
if (!q.prepare(queryString)) {
|
||||
|
||||
QuasarAppUtils::Params::log("Failed to prepare query: " + q.lastError().text(),
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Failed to prepare query: " + q.lastError().text();
|
||||
return PrepareResult::Fail;
|
||||
}
|
||||
|
||||
@ -59,8 +58,7 @@ PrepareResult SetSingleValue::prepareInsertQuery(QSqlQuery &q, bool replace) con
|
||||
|
||||
if (!q.prepare(queryString)) {
|
||||
|
||||
QuasarAppUtils::Params::log("Failed to prepare query: " + q.lastError().text(),
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Failed to prepare query: " + q.lastError().text();
|
||||
return PrepareResult::Fail;
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,10 @@ QH::SoftDelete::~SoftDelete() {
|
||||
|
||||
if (!fSoftDelete) {
|
||||
|
||||
QuasarAppUtils::Params::log(QString("You delete %0 without preparing. "
|
||||
"All changes can not be saved. "
|
||||
"For fix it trouble use the softDelete method.").arg(typeid (this).name()),
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "You delete %0 without preparing. " << typeid (this).name() <<
|
||||
"The object was deleted without preparing. All changes can not be saved. "
|
||||
"For fix it trouble use the softDelete method.";
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
std::abort();
|
||||
#endif
|
||||
|
@ -51,9 +51,7 @@ bool SqlDBWriter::exec(QSqlQuery *sq, const QString& sqlFile) const {
|
||||
temp = temp.remove(0, delimiterIndex + 1);
|
||||
|
||||
if (!result) {
|
||||
QuasarAppUtils::Params::log(QString("Exec database error. File: %0. Line:%1: %2").
|
||||
arg(sqlFile).arg(lineNumber).arg(sq->lastError().text()),
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Exec database error. File: " << sqlFile << " Line:" << lineNumber << sq->lastError().text();
|
||||
f.close();
|
||||
return false;
|
||||
}
|
||||
@ -64,8 +62,7 @@ bool SqlDBWriter::exec(QSqlQuery *sq, const QString& sqlFile) const {
|
||||
return result;
|
||||
}
|
||||
|
||||
QuasarAppUtils::Params::log("sql source file is not open: " + sqlFile,
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "sql source file is not open: " << sqlFile;
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -106,8 +103,7 @@ bool SqlDBWriter::initDbPrivate(const QVariantMap ¶ms) {
|
||||
}
|
||||
|
||||
if (!_db->open()) {
|
||||
QuasarAppUtils::Params::log(_db->lastError().text(),
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << _db->lastError().text();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -140,8 +136,7 @@ bool SqlDBWriter::doQueryPrivate(const QString &query, const QVariantMap &bindVa
|
||||
QSqlQuery q(*db());
|
||||
if (bindValues.size()) {
|
||||
if (!q.prepare(query)) {
|
||||
QuasarAppUtils::Params::log("request error : " + q.lastError().text(),
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "request error : " << q.lastError().text();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -150,14 +145,14 @@ bool SqlDBWriter::doQueryPrivate(const QString &query, const QVariantMap &bindVa
|
||||
}
|
||||
|
||||
if (!q.exec()) {
|
||||
QuasarAppUtils::Params::log("request error : " + q.lastError().text(),
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "execute error : " << q.lastError().text();
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!q.exec(query)) {
|
||||
QuasarAppUtils::Params::log("request error : " + q.lastError().text(),
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "bind values error : " << q.lastError().text();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -187,7 +182,7 @@ bool SqlDBWriter::enableFK() {
|
||||
QSqlQuery query(*db());
|
||||
QString request = QString("PRAGMA foreign_keys = ON");
|
||||
if (!query.exec(request)) {
|
||||
QuasarAppUtils::Params::log("request error : " + query.lastError().text());
|
||||
qDebug() << "request error : " << query.lastError().text();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -203,7 +198,7 @@ bool SqlDBWriter::disableFK() {
|
||||
QSqlQuery query(*db());
|
||||
QString request = QString("PRAGMA foreign_keys = OFF");
|
||||
if (!query.exec(request)) {
|
||||
QuasarAppUtils::Params::log("request error : " + query.lastError().text());
|
||||
qDebug() << "request error : " << query.lastError().text();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -454,10 +449,8 @@ bool SqlDBWriter::selectQuery(const DBObject& requestObject,
|
||||
|
||||
while (q.next()) {
|
||||
if (!newObject->fromSqlRecord(q.record())) {
|
||||
QuasarAppUtils::Params::log("Select query finished successful but, "
|
||||
"the fromSqlRecord method return false." +
|
||||
newObject->toString(),
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Select query finished successful but, "
|
||||
"the fromSqlRecord method return false." << newObject->toString();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -472,8 +465,7 @@ bool SqlDBWriter::selectQuery(const DBObject& requestObject,
|
||||
return false;
|
||||
|
||||
if (!newObject->fromSqlRecord(q.record())) {
|
||||
QuasarAppUtils::Params::log("Init sql object error.",
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "Init sql object error.";
|
||||
return false;
|
||||
}
|
||||
result.push_back(newObject);
|
||||
@ -527,11 +519,9 @@ bool SqlDBWriter::workWithQuery(QSqlQuery &q,
|
||||
|
||||
auto printError = [](const QSqlQuery &q) {
|
||||
|
||||
QuasarAppUtils::Params::log("prepare sql error: " + q.executedQuery(),
|
||||
QuasarAppUtils::Debug);
|
||||
qDebug() << "prepare sql error: " << q.lastError().text();
|
||||
|
||||
QuasarAppUtils::Params::log("exec sql error: " + q.lastError().text(),
|
||||
QuasarAppUtils::Error);
|
||||
qCritical() << "exec sql error: " << q.lastError();
|
||||
|
||||
};
|
||||
|
||||
@ -545,17 +535,16 @@ bool SqlDBWriter::workWithQuery(QSqlQuery &q,
|
||||
}
|
||||
|
||||
#ifdef HEART_PRINT_SQL_QUERIES
|
||||
QuasarAppUtils::Params::log(QString("Query executed successfull into %0\n"
|
||||
"query: %1").
|
||||
arg(_db->databaseName(), q.executedQuery()),
|
||||
QuasarAppUtils::Debug);
|
||||
qDebug() << QString("Query executed successfull into %0\n"
|
||||
"query: %1").
|
||||
arg(_db->databaseName(), q.executedQuery();
|
||||
#endif
|
||||
|
||||
return cb();
|
||||
}
|
||||
case PrepareResult::Disabled: {
|
||||
QuasarAppUtils::Params::log("call disabled operator! ",
|
||||
QuasarAppUtils::Warning);
|
||||
|
||||
qWarning() << "call disabled operator!";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user