completed logger usage and changed shred task to non-static

This commit is contained in:
2020-09-08 13:01:09 +02:00
parent 730b1205f7
commit 938f267813
5 changed files with 80 additions and 44 deletions

View File

@ -104,6 +104,7 @@ void reHDD::ThreadScannDevices()
addSMARTData(&vecNewDrives); //add S.M.A.R.T. Data to the drives
mxScannDrives.unlock();
write(fdNewDrivesInformPipe[1], "A",1);
printDrives(&vecNewDrives);
sleep(5); //sleep 5 sec
}
}
@ -177,8 +178,9 @@ void reHDD::ThreadShred()
{
if (getSelectedDrive() != nullptr)
{
Shred::shredDrive(getSelectedDrive(), &fdShredInformPipe[1]);
Logger::logThis()->info("Finished shred for: " + getSelectedDrive()->getModelName() + "-" + getSelectedDrive()->getSerial());
Shred* pShredTask = new Shred(); //create new shred task
pShredTask->shredDrive(getSelectedDrive(), &fdShredInformPipe[1]); //start new shred task
delete pShredTask; //delete shred task
ui->updateTUI(&vecDrives, u8SelectedEntry);
}
}
@ -216,7 +218,6 @@ void reHDD::filterNewDrives(vector <Drive>* pvecOldDrives, vector <Drive>* pvecN
for (long unsigned int i=0; i<pvecNewDrives->size(); i++)
{
pvecOldDrives->push_back((*pvecNewDrives)[i]);
Logger::logThis()->info("Attached drive: " + i + string("-") + pvecNewDrives->at(i).getPath());
}
}
@ -228,6 +229,7 @@ void reHDD::filterNewDrives(vector <Drive>* pvecOldDrives, vector <Drive>* pvecN
void reHDD::searchDrives(vector <Drive>* pvecDrives)
{
// cout << "search drives ..." << endl;
Logger::logThis()->info("--> search drives <--");
char * cLine = NULL;
size_t len = 0;
@ -324,7 +326,9 @@ void reHDD::filterIgnoredDrives(vector <Drive>* pvecDrives)
else
{
// same uuid found than in ignore file --> ignore this drive
#ifdef LOG_LEVEL_HIGH
Logger::logThis()->info("same uuid found than in ignore file --> ignore this drive: " + it->getPath());
#endif
it = pvecDrives->erase(it);
it--;
}
@ -340,22 +344,28 @@ void reHDD::filterIgnoredDrives(vector <Drive>* pvecDrives)
*/
void reHDD::printDrives(vector <Drive>* pvecDrives)
{
cout << "------------DRIVES---------------" << endl;
#ifdef LOG_LEVEL_HIGH
Logger::logThis()->info("------------DRIVES---------------");
//cout << "------------DRIVES---------------" << endl;
vector <Drive>::iterator it;
for (it = pvecDrives->begin(); it != pvecDrives->end(); ++it)
{
cout << " Drive: " << distance(pvecDrives->begin(), it) << endl;
cout << "Path: " << it->getPath() << endl;
cout << "ModelFamily: " << it->getModelFamily() << endl;
cout << "ModelName: " << it->getModelName() << endl;
cout << "Capacity: " << it->getCapacity() << endl;
cout << "Serial: " << it->getSerial() << endl;
cout << "PowerOnHours: " << it->getPowerOnHours() << endl;
cout << "PowerCycle: " << it->getPowerCycles() << endl;
cout << "ErrorCount: " << it->getErrorCount() << endl;
cout << endl;
/*
cout << " Drive: " << distance(pvecDrives->begin(), it) << endl;
cout << "Path: " << it->getPath() << endl;
cout << "ModelFamily: " << it->getModelFamily() << endl;
cout << "ModelName: " << it->getModelName() << endl;
cout << "Capacity: " << it->getCapacity() << endl;
cout << "Serial: " << it->getSerial() << endl;
cout << "PowerOnHours: " << it->getPowerOnHours() << endl;
cout << "PowerCycle: " << it->getPowerCycles() << endl;
cout << "ErrorCount: " << it->getErrorCount() << endl;
cout << endl;*/
Logger::logThis()->info(to_string(it - pvecDrives->begin()) + ": " + it->getPath() + " - " + it->getModelFamily() + " - " + it->getSerial());
}
cout << "---------------------------------" << endl;
Logger::logThis()->info("---------------------------------");
//cout << "---------------------------------" << endl;
#endif
}
/**
@ -400,7 +410,7 @@ void reHDD::handleArrowKey(TUI::UserInput userInput)
break;
}
Logger::logThis()->info("ArrowKey - selected drive: " + to_string(u8SelectedEntry));
Logger::logThis()->info("ArrowKey - selected drive: " + to_string(u8SelectedEntry));
}
void reHDD::handleEnter()