figments: mainloop: print warning if task couldnt be found

This commit is contained in:
Torrie Fischer 2023-12-11 07:49:23 +01:00
parent 1e2f60201d
commit 7970192c1a

View File

@ -24,17 +24,23 @@ MainLoop::dispatchSync(const InputEvent& evt)
{ {
if (evt.intent == InputEvent::StartThing || evt.intent == InputEvent::StopThing) { if (evt.intent == InputEvent::StartThing || evt.intent == InputEvent::StopThing) {
const bool jobState = (evt.intent == InputEvent::StartThing); const bool jobState = (evt.intent == InputEvent::StartThing);
bool wasFound = false;
for(auto figmentJob: scheduler.tasks) { for(auto figmentJob: scheduler.tasks) {
if (!strcmp(figmentJob->name, evt.asString())) { if (!strcmp(figmentJob->name, evt.asString())) {
if (jobState) { if (jobState) {
Log.trace("** Starting %s", figmentJob->name); Log.trace("** Starting %s", figmentJob->name);
figmentJob->start(); figmentJob->start();
wasFound = true;
} else { } else {
Log.trace("** Stopping %s", figmentJob->name); Log.trace("** Stopping %s", figmentJob->name);
figmentJob->stop(); figmentJob->stop();
wasFound = true;
} }
} }
} }
if (!wasFound) {
Log.warning("** Unable to find task %s", evt.asString());
}
} }
for(Task* task : scheduler) { for(Task* task : scheduler) {