diff --git a/libnymea-core/logging/logengine.cpp b/libnymea-core/logging/logengine.cpp index e49fb795..4ea50eda 100644 --- a/libnymea-core/logging/logengine.cpp +++ b/libnymea-core/logging/logengine.cpp @@ -183,8 +183,6 @@ LogEngine::~LogEngine() */ QList LogEngine::logEntries(const LogFilter &filter) const { - qCDebug(dcLogEngine) << "Read logging database" << m_db.databaseName(); - QList results; QSqlQuery query; diff --git a/libnymea-core/ruleengine.cpp b/libnymea-core/ruleengine.cpp index a37fb930..47b8b9a8 100644 --- a/libnymea-core/ruleengine.cpp +++ b/libnymea-core/ruleengine.cpp @@ -333,8 +333,15 @@ RuleEngine::~RuleEngine() QList RuleEngine::evaluateEvent(const Event &event) { Device *device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(event.deviceId()); + DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId()); + EventType eventType = deviceClass.eventTypes().findById(event.eventTypeId()); - qCDebug(dcRuleEngineDebug) << "Evaluate event:" << event << device->name() << event.eventTypeId(); + + if (event.params().count() == 0) { + qCDebug(dcRuleEngineDebug).nospace().noquote() << "Evaluate event: " << device->name() << " - " << eventType.name() << " (DeviceId:" << device->id().toString() << ", EventTypeId:" << eventType.id().toString() << ")"; + } else { + qCDebug(dcRuleEngineDebug).nospace().noquote() << "Evaluate event: " << device->name() << " - " << eventType.name() << " (DeviceId:" << device->id().toString() << ", EventTypeId:" << eventType.id().toString() << ")" << endl << " " << event.params(); + } QList rules; foreach (const RuleId &id, ruleIds()) { diff --git a/libnymea-core/stateevaluator.cpp b/libnymea-core/stateevaluator.cpp index 3719a896..a6911c99 100644 --- a/libnymea-core/stateevaluator.cpp +++ b/libnymea-core/stateevaluator.cpp @@ -99,52 +99,54 @@ void StateEvaluator::setOperatorType(Types::StateOperator operatorType) /*! Returns true, if all child evaluator conditions are true depending on the \l {Types::StateOperator}{StateOperator}.*/ bool StateEvaluator::evaluate() const { - qCDebug(dcRuleEngineDebug()) << "Evaluating StateEvaluator." << this << "Operator type" << m_operatorType << "Valid descriptor:" << m_stateDescriptor.isValid() << "Childs:" << m_childEvaluators.count(); + qCDebug(dcRuleEngineDebug()) << "StateEvaluator:" << this << "Evaluating: Operator type" << m_operatorType << "Valid descriptor:" << m_stateDescriptor.isValid() << "Childs:" << m_childEvaluators.count(); bool descriptorMatching = true; if (m_stateDescriptor.isValid()) { Device *device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(m_stateDescriptor.deviceId()); if (!device) { - qCWarning(dcRuleEngine) << "Device not existing!"; + qCWarning(dcRuleEngine) << "StateEvaluator:" << this << "Device not existing!"; descriptorMatching = false; } else { DeviceClass deviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId()); if (!device->hasState(m_stateDescriptor.stateTypeId())) { - qCWarning(dcRuleEngine) << "Device found, but it does not appear to have such a state!"; + qCWarning(dcRuleEngine) << "StateEvaluator:" << this << "Device found, but it does not appear to have such a state!"; descriptorMatching = false; } if (m_stateDescriptor != device->state(m_stateDescriptor.stateTypeId())) { // state not matching - qCDebug(dcRuleEngineDebug()) << "State" << device->name() << deviceClass.stateTypes().findById(m_stateDescriptor.stateTypeId()).name() << "not matching:" << m_stateDescriptor.stateValue() << "!=" << device->stateValue(m_stateDescriptor.stateTypeId()); descriptorMatching = false; } + qCDebug(dcRuleEngineDebug()) << "StateEvaluator:" << this << "State" << device->name() << deviceClass.stateTypes().findById(m_stateDescriptor.stateTypeId()).name() << (descriptorMatching ? "is" : "not") << "matching:" << m_stateDescriptor.stateValue() << m_stateDescriptor.operatorType() << device->stateValue(m_stateDescriptor.stateTypeId()); } } if (m_operatorType == Types::StateOperatorOr) { if (m_stateDescriptor.isValid() && descriptorMatching) { - qCDebug(dcRuleEngineDebug()) << "Descriptor is matching. Operator is OR => Evaluation result: true"; + qCDebug(dcRuleEngineDebug()) << "StateEvaluator:" << this << "Descriptor is matching. Operator is OR => Evaluation result: true"; return true; } foreach (const StateEvaluator &stateEvaluator, m_childEvaluators) { if (stateEvaluator.evaluate()) { - qCDebug(dcRuleEngineDebug()) << "Child evaluator evaluated to true. Operator is OR => Evaluation result: true"; + qCDebug(dcRuleEngineDebug()) << "StateEvaluator:" << this << "Child evaluator evaluated to true. Operator is OR => Evaluation result: true"; return true; } } - qCDebug(dcRuleEngineDebug()) << "No child evaluator evaluated to true => Evaluation result: false"; + qCDebug(dcRuleEngineDebug()) << "StateEvaluator:" << this << "No child evaluator evaluated to true => Evaluation result: false"; return false; } if (!descriptorMatching) { - qCDebug(dcRuleEngineDebug()) << "Operator is AND => Evaluation result: false"; + qCDebug(dcRuleEngineDebug()) << "StateEvaluator:" << this << "StateDescriptor not matching and operator is AND => Evaluation result: false"; return false; } foreach (const StateEvaluator &stateEvaluator, m_childEvaluators) { if (!stateEvaluator.evaluate()) { + qCDebug(dcRuleEngineDebug()) << "StateEvaluator:" << this << "Child evaluator not matching => Evaluation result: false"; return false; } } + qCDebug(dcRuleEngineDebug()) << "StateEvaluator:" << this << "StateDescriptor and all child evaluators matching => Evaluation result: true"; return true; } diff --git a/libnymea/types/param.cpp b/libnymea/types/param.cpp index 3737f60f..6b2993a4 100644 --- a/libnymea/types/param.cpp +++ b/libnymea/types/param.cpp @@ -76,9 +76,12 @@ QDebug operator<<(QDebug dbg, const Param ¶m) /*! Writes the param of the given \a params to \a dbg. */ QDebug operator<<(QDebug dbg, const ParamList ¶ms) { - dbg.nospace() << "ParamList (count:" << params.count() << ")" << endl; + dbg.nospace() << "ParamList (count:" << params.count() << ")"; + if (params.count() == 0) { + dbg.nospace() << endl; + } for (int i = 0; i < params.count(); i++ ) { - dbg.nospace() << " " << i << ": " << params.at(i) << endl; + dbg.nospace() << endl << " " << i << ": " << params.at(i); } return dbg.space(); diff --git a/plugins/mock/devicepluginmock.cpp b/plugins/mock/devicepluginmock.cpp index 743c166d..66640ea1 100644 --- a/plugins/mock/devicepluginmock.cpp +++ b/plugins/mock/devicepluginmock.cpp @@ -104,7 +104,7 @@ DeviceManager::DeviceSetupStatus DevicePluginMock::setupDevice(Device *device) m_daemons.insert(device, daemon); if (!daemon->isListening()) { - qCWarning(dcMockDevice) << "HTTP port opening failed."; + qCWarning(dcMockDevice) << "HTTP port opening failed:" << device->paramValue(mockHttpportParamTypeId).toInt(); return DeviceManager::DeviceSetupStatusFailure; }