Is there a way to check if the on-going log contains a string?

Hello,

I have a workflow that is responsible for running UI tests. During the execution of this workflow, I want to mark the build as failed or even stop (cancel) when a string is encountered in the log (step).
I was searching for something like this: Build Failure Conditions | TeamCity On-Premises but no luck so far. I am inclined to check the logs (using octokit) after each step but
that does not seem optimal. Is there another way to do this ?