I believe I found a solution for such a problem. There is a class called KeywordLogger, which can write into a log. So just create an instance of it and call logFailed() method.
KeywordLogger log = new KeywordLogger()
log.logFailed("Failed 1")
log.logFailed("Failed 2")
log.logFailed("Failed 3")
There are 3 FAILED level logs after execution. And that’s it.