Updates:
Status: Accepted
Comment #1 on issue 548 by pekka.klarck: Logging from Listener
http://code.google.com/p/robotframework/issues/detail?id=548
First of all, sorry for not responding earlier after I asked you to submit
this issue
on the mailing list. I both good and bad news for you, and I'll start with
the latter.
I have looked at this briefly, and it seems that adding real support for
this
functionality isn't that easy currently. At least it's not easy enough to
be added to
the already full 2.5 schedule.
In RF 2.6 we are going to refactor how tests are run and adding this
feature ought to
be easier then. I'd also like to get the bigger listener changes proposed
in issue
177 in at that time. If someone is interested to investigate this earlier,
adding the
functionality into some 2.5.x version is possible too.
The good news is that to some extend this already works. I just tested,
both with RF
2.1.3 and RF 2.5 RC 1, that the code below actually does log the specified
message
inside the executed keyword. Notice that the example uses internal APIs
that are
likely to change when running is refactored in RF 2.6. I thus recommend
anyone using
this approach to use it so that the implementation can be changed easily
later. I
also tested that the same approach didn't work in end_keyword, and it
probably
doesn't work in other listener methods either.
------------8<----------------------8<------------------------
from robot.output import LOGGER
from robot.output.loggerhelper import Message
ROBOT_LISTENER_API_VERSION = 2
def start_keyword(name, attrs):
LOGGER.log_message(Message('Hello, world!', 'INFO'))