Improve logging for macros

This commit is contained in:
WarmUpTill
2021-05-19 20:46:13 +02:00
committed by WarmUpTill
parent 51680adc20
commit 72bd905e7c
5 changed files with 25 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ public:
static QWidget *CreateWidget(const int id, QWidget *parent,
std::shared_ptr<MacroAction> action);
static auto GetActionTypes() { return _methods; }
static std::string GetActionName(int id);
private:
static std::map<int, MacroActionInfo> _methods;

View File

@@ -25,6 +25,7 @@ public:
static QWidget *CreateWidget(const int id, QWidget *parent,
std::shared_ptr<MacroCondition>);
static auto GetConditionTypes() { return _methods; }
static std::string GetConditionName(int id);
private:
static std::map<int, MacroConditionInfo> _methods;

View File

@@ -31,6 +31,14 @@ QWidget *MacroActionFactory::CreateWidget(const int id, QWidget *parent,
return nullptr;
}
std::string MacroActionFactory::GetActionName(int id)
{
if (auto it = _methods.find(id); it != _methods.end()) {
return it->second._name;
}
return "unknown action";
}
static inline void populateActionSelection(QComboBox *list)
{
for (auto entry : MacroActionFactory::GetActionTypes()) {

View File

@@ -29,6 +29,14 @@ MacroConditionFactory::CreateWidget(const int id, QWidget *parent,
return nullptr;
}
std::string MacroConditionFactory::GetConditionName(int id)
{
if (auto it = _methods.find(id); it != _methods.end()) {
return it->second._name;
}
return "unknown condition";
}
static inline void populateLogicSelection(QComboBox *list, bool root = false)
{
if (root) {

View File

@@ -55,8 +55,13 @@ bool Macro::CeckMatch()
_name.c_str());
break;
}
vblog(LOG_INFO, "condition %s returned %d",
MacroConditionFactory::GetConditionName(c->GetId())
.c_str(),
cond);
}
vblog(LOG_INFO, "Macro %s returned %d", _name.c_str(), _matched);
return _matched;
}
@@ -232,7 +237,8 @@ bool MacroAction::Load(obs_data_t *obj)
void MacroAction::LogAction()
{
blog(LOG_INFO, "performed action %d", GetId());
vblog(LOG_INFO, "performed action %s",
MacroActionFactory::GetActionName(GetId()).c_str());
}
void SwitcherData::saveMacros(obs_data_t *obj)