Added Utils::error() and Utils::info() to print to stderr/stdout instead of qDebug()
This commit is contained in:
@@ -58,14 +58,14 @@ AddFileResult CommandAdd::addFile(QString path)
|
||||
|
||||
if(pageData.isEmpty())
|
||||
{
|
||||
qDebug() << "Could not get any content for " << absPath;
|
||||
Utils::error() << "Could not get any content for " << absPath << endl;
|
||||
}
|
||||
|
||||
// Workaround to "database is locked" error. Perhaps try WAL mode etc.
|
||||
// QMutexLocker locker(&writeMutex);
|
||||
if(!db.transaction())
|
||||
{
|
||||
qDebug() << "Failed to open transaction for " << absPath << " : " << db.lastError();
|
||||
Utils::error() << "Failed to open transaction for " << absPath << " : " << db.lastError() << endl;
|
||||
return DBFAIL;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ AddFileResult CommandAdd::addFile(QString path)
|
||||
delQuery.addBindValue(absPath);
|
||||
if(!delQuery.exec())
|
||||
{
|
||||
qDebug() << "Failed DELETE query" << delQuery.lastError();
|
||||
Utils::error() << "Failed DELETE query" << delQuery.lastError() << endl;
|
||||
db.rollback();
|
||||
return DBFAIL;
|
||||
}
|
||||
@@ -85,7 +85,7 @@ AddFileResult CommandAdd::addFile(QString path)
|
||||
inserterQuery.addBindValue(fileType);
|
||||
if(!inserterQuery.exec())
|
||||
{
|
||||
qDebug() << "Failed INSERT query" << inserterQuery.lastError();
|
||||
Utils::error() << "Failed INSERT query" << inserterQuery.lastError() << endl;
|
||||
db.rollback();
|
||||
return DBFAIL;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ AddFileResult CommandAdd::addFile(QString path)
|
||||
if(!contentQuery.exec())
|
||||
{
|
||||
db.rollback();
|
||||
qDebug() << "Failed content insertion " << contentQuery.lastError();
|
||||
Utils::error() << "Failed content insertion " << contentQuery.lastError() << endl;
|
||||
return DBFAIL;
|
||||
}
|
||||
}
|
||||
@@ -107,7 +107,7 @@ AddFileResult CommandAdd::addFile(QString path)
|
||||
if(!db.commit())
|
||||
{
|
||||
db.rollback();
|
||||
qDebug() << "Failed to commit transaction for " << absPath << " : " << db.lastError();
|
||||
Utils::error() << "Failed to commit transaction for " << absPath << " : " << db.lastError() << endl;
|
||||
return DBFAIL;
|
||||
}
|
||||
return OK;
|
||||
@@ -168,12 +168,12 @@ int CommandAdd::handle(QStringList arguments)
|
||||
}
|
||||
if(verbose)
|
||||
{
|
||||
qDebug() << "Processing " << path;
|
||||
Utils::info() << "Processing " << path << endl;
|
||||
}
|
||||
auto result = addFile(path);
|
||||
if(result == DBFAIL)
|
||||
{
|
||||
qDebug() << "Failed to add " << path;
|
||||
Utils::error() << "Failed to add " << path << endl;
|
||||
if(!keepGoing)
|
||||
{
|
||||
terminate = true;
|
||||
@@ -183,11 +183,12 @@ int CommandAdd::handle(QStringList arguments)
|
||||
{
|
||||
if(result == SKIPPED)
|
||||
{
|
||||
qDebug() << "Skipped" << path << "as it already exists in the database";
|
||||
Utils::info()
|
||||
<< "Skipped" << path << "as it already exists in the database" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Added" << path;
|
||||
Utils::info() << "Added" << path << endl;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user