Update debug categories and use qInfo, fix vietual destructor for the monitor
This commit is contained in:
parent
76b7bc1267
commit
66d62b87de
@ -142,6 +142,7 @@ bool MacAddressDatabase::initDatabase()
|
||||
return false;
|
||||
}
|
||||
|
||||
qCInfo(dcMacAddressDatabase()) << "Database initialized successfully" << m_databaseName;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -163,7 +164,7 @@ void MacAddressDatabase::onLookupFinished()
|
||||
{
|
||||
if (m_currentReply) {
|
||||
QString manufacturer = m_futureWatcher->future().result();
|
||||
qCDebug(dcMacAddressDatabase()) << "Manufacturer lookup for" << m_currentReply->macAddress() << "finished:" << manufacturer << QDateTime::currentMSecsSinceEpoch() - m_currentReply->m_startTimestamp << "ms";
|
||||
qCInfo(dcMacAddressDatabase()) << "Manufacturer lookup for" << m_currentReply->macAddress() << "finished:" << manufacturer << QDateTime::currentMSecsSinceEpoch() - m_currentReply->m_startTimestamp << "ms";
|
||||
m_currentReply->m_manufacturer = manufacturer;
|
||||
emit m_currentReply->finished();
|
||||
m_currentReply = nullptr;
|
||||
@ -174,7 +175,7 @@ void MacAddressDatabase::onLookupFinished()
|
||||
|
||||
QString MacAddressDatabase::lookupMacAddressVendorInternal(const QString &macAddress)
|
||||
{
|
||||
qCDebug(dcMacAddressDatabase()) << "Start looking up vendor for" << macAddress;
|
||||
qCInfo(dcMacAddressDatabase()) << "Start looking up vendor for" << macAddress;
|
||||
// Convert the mac address string to upper like in the database and remove : since they have been removed for size reasons
|
||||
QString fullMacAddressString = QString(macAddress).toUpper().remove(":");
|
||||
|
||||
|
||||
@ -78,7 +78,7 @@ NetworkDeviceDiscoveryImpl::NetworkDeviceDiscoveryImpl(QObject *parent) :
|
||||
if (!arpAvailable && !m_ping->available()) {
|
||||
qCWarning(dcNetworkDeviceDiscovery()) << "Network device discovery is not available on this system.";
|
||||
} else {
|
||||
qCDebug(dcNetworkDeviceDiscovery()) << "Created successfully";
|
||||
qCInfo(dcNetworkDeviceDiscovery()) << "Created successfully";
|
||||
}
|
||||
|
||||
m_cacheSettings = new QSettings(NymeaSettings::cachePath() + "/network-device-discovery.cache", QSettings::IniFormat);
|
||||
@ -100,7 +100,7 @@ NetworkDeviceDiscoveryReply *NetworkDeviceDiscoveryImpl::discover()
|
||||
return m_currentReply;
|
||||
}
|
||||
|
||||
qCDebug(dcNetworkDeviceDiscovery()) << "Starting network device discovery ...";
|
||||
qCInfo(dcNetworkDeviceDiscovery()) << "Starting network device discovery ...";
|
||||
m_currentReply = new NetworkDeviceDiscoveryReplyImpl(this);
|
||||
connect(m_currentReply, &NetworkDeviceDiscoveryReplyImpl::networkDeviceInfoAdded, this, &NetworkDeviceDiscoveryImpl::updateCache);
|
||||
|
||||
@ -135,7 +135,7 @@ bool NetworkDeviceDiscoveryImpl::running() const
|
||||
|
||||
NetworkDeviceMonitor *NetworkDeviceDiscoveryImpl::registerMonitor(const MacAddress &macAddress)
|
||||
{
|
||||
qCDebug(dcNetworkDeviceDiscovery()) << "Register new network device monitor for" << macAddress;
|
||||
qCInfo(dcNetworkDeviceDiscovery()) << "Register new network device monitor for" << macAddress;
|
||||
// Make sure we creare only one monitor per mac
|
||||
if (m_monitors.contains(macAddress))
|
||||
return m_monitors.value(macAddress);
|
||||
@ -175,7 +175,7 @@ void NetworkDeviceDiscoveryImpl::unregisterMonitor(const MacAddress &macAddress)
|
||||
{
|
||||
if (m_monitors.contains(macAddress)) {
|
||||
NetworkDeviceMonitor *monitor = m_monitors.take(macAddress);
|
||||
qCDebug(dcNetworkDeviceDiscovery()) << "Unregister" << monitor;
|
||||
qCInfo(dcNetworkDeviceDiscovery()) << "Unregister" << monitor;
|
||||
monitor->deleteLater();
|
||||
}
|
||||
}
|
||||
@ -319,7 +319,7 @@ void NetworkDeviceDiscoveryImpl::processMonitorPingResult(PingReply *reply, Netw
|
||||
|
||||
void NetworkDeviceDiscoveryImpl::loadNetworkDeviceCache()
|
||||
{
|
||||
qCDebug(dcNetworkDeviceDiscovery()) << "Loading cached network device information from" << m_cacheSettings->fileName();
|
||||
qCInfo(dcNetworkDeviceDiscovery()) << "Loading cached network device information from" << m_cacheSettings->fileName();
|
||||
|
||||
m_networkInfoCache.clear();
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
@ -548,7 +548,7 @@ void NetworkDeviceDiscoveryImpl::evaluateMonitors()
|
||||
evaluateMonitor(monitor);
|
||||
|
||||
// Check if there is any monitor which has not be seen since
|
||||
if (monitor->lastConnectionAttempt().isValid() && longerAgoThan(monitor->lastSeen(), m_monitorInterval)) {
|
||||
if (!monitor->reachable() && monitor->lastConnectionAttempt().isValid() && longerAgoThan(monitor->lastSeen(), m_monitorInterval)) {
|
||||
monitorRequiresRediscovery = true;
|
||||
}
|
||||
}
|
||||
@ -560,7 +560,7 @@ void NetworkDeviceDiscoveryImpl::evaluateMonitors()
|
||||
|
||||
// Do some cache housekeeping if required
|
||||
if (m_lastCacheHousekeeping.addDays(1) < QDateTime::currentDateTime()) {
|
||||
qCDebug(dcNetworkDeviceDiscovery()) << "Starting cache housekeeping since it is more than one day since the last clanup...";
|
||||
qCInfo(dcNetworkDeviceDiscovery()) << "Starting cache housekeeping since it is more than one day since the last clanup...";
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
foreach (const MacAddress &mac, m_lastSeen.keys()) {
|
||||
// Remove the info from the cache if not seen fo the last 30 days...
|
||||
|
||||
@ -181,7 +181,7 @@ void NetworkDeviceDiscoveryReplyImpl::processDiscoveryFinished()
|
||||
m_networkDeviceInfos.sortNetworkDevices();
|
||||
|
||||
qint64 durationMilliSeconds = QDateTime::currentMSecsSinceEpoch() - m_startTimestamp;
|
||||
qCDebug(dcNetworkDeviceDiscovery()) << "Discovery finished. Found" << networkDeviceInfos().count() << "network devices in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
qCInfo(dcNetworkDeviceDiscovery()) << "Discovery finished. Found" << networkDeviceInfos().count() << "network devices in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
|
||||
// Process what's left and add it to result list
|
||||
foreach (const NetworkDeviceInfo &info, m_networkDeviceInfos) {
|
||||
|
||||
@ -346,7 +346,7 @@ void ArpSocket::processDataBuffer(unsigned char *receiveBuffer, int size)
|
||||
|
||||
QNetworkInterface networkInterface = NetworkUtils::getInterfaceForHostaddress(senderHostAddress);
|
||||
if (!networkInterface.isValid()) {
|
||||
qCWarning(dcArpSocket()) << "Could not find local interface from ARP request" << senderHostAddress.toString() << senderMacAddress.toString();
|
||||
qCDebug(dcArpSocket()) << "Could not find local interface from ARP request" << senderHostAddress.toString() << senderMacAddress.toString();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -361,7 +361,7 @@ void ArpSocket::processDataBuffer(unsigned char *receiveBuffer, int size)
|
||||
case ARPOP_REPLY: {
|
||||
QNetworkInterface networkInterface = NetworkUtils::getInterfaceForMacAddress(targetMacAddress);
|
||||
if (!networkInterface.isValid()) {
|
||||
qCWarning(dcArpSocket()) << "Could not find local interface from ARP response" << targetHostAddress.toString() << targetMacAddress.toString();
|
||||
qCDebug(dcArpSocket()) << "Could not find local interface from ARP response" << targetHostAddress.toString() << targetMacAddress.toString();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -44,6 +44,7 @@ class LIBNYMEA_EXPORT NetworkDeviceMonitor : public QObject
|
||||
|
||||
public:
|
||||
explicit NetworkDeviceMonitor(QObject *parent = nullptr);
|
||||
virtual ~NetworkDeviceMonitor();
|
||||
|
||||
virtual MacAddress macAddress() const = 0;
|
||||
|
||||
|
||||
@ -418,7 +418,7 @@ void Ping::onHostLookupFinished(const QHostInfo &info)
|
||||
if (info.error() != QHostInfo::NoError) {
|
||||
qCWarning(dcPing()) << "Failed to look up hostname after successfull ping" << reply->targetHostAddress().toString() << info.error();
|
||||
} else {
|
||||
qCDebug(dcPing()) << "******** Looked up hostname after successfull ping" << reply->targetHostAddress().toString() << info.hostName();
|
||||
qCDebug(dcPing()) << "Looked up hostname after successfull ping" << reply->targetHostAddress().toString() << info.hostName();
|
||||
if (info.hostName() != reply->targetHostAddress().toString()) {
|
||||
reply->m_hostName = info.hostName();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user