Improve logging to only log successful sensor enumerations
This commit is contained in:
parent
4469cfb114
commit
1c1721c720
@ -13,7 +13,8 @@ int main(int argc, char* argv[])
|
||||
qInstallMessageHandler(logToFile);
|
||||
QApplication application(argc, argv);
|
||||
|
||||
qDebug("Starting application");
|
||||
qInfo(ltr("")); // New line for better visibility between runs
|
||||
qDebug(ltr("Starting application"));
|
||||
|
||||
SensorDriver sensorDriver;
|
||||
|
||||
|
@ -40,7 +40,7 @@ std::vector<int> SensorDriver::Sensor::readValues()
|
||||
|
||||
SensorDriver::Sensor::Sensor(const QString& serialPortName) : m_serialPortName(serialPortName)
|
||||
{
|
||||
qInfo(ltr("Creating sensor on serial port %1").arg(m_serialPortName));
|
||||
qDebug(ltr("Creating sensor on serial port %1").arg(m_serialPortName));
|
||||
}
|
||||
|
||||
bool SensorDriver::Sensor::isValidSensor()
|
||||
@ -178,12 +178,13 @@ std::vector<SensorDriver::Sensor> SensorDriver::enumerateSensors() const
|
||||
|
||||
const auto portsInfo = QSerialPortInfo::availablePorts();
|
||||
|
||||
qInfo(ltr("Found %1 serial ports").arg(portsInfo.count()));
|
||||
qDebug(ltr("Found %1 serial ports").arg(portsInfo.count()));
|
||||
|
||||
for(const auto& portInfo: portsInfo) {
|
||||
qDebug(ltr("Checking port %1").arg(portInfo.portName()));
|
||||
auto sensor = Sensor(portInfo.portName());
|
||||
if(sensor.isValidSensor()) {
|
||||
qInfo(ltr("Successfully enumerated sensor on port %1").arg(portInfo.portName()));
|
||||
sensors.push_back(sensor);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user