Logging redirect to console

133 views
Skip to first unread message

Sean Wu

unread,
May 13, 2016, 12:02:24 PM5/13/16
to robotframework-users
Is there a way to turn on redirect logging to console? by default, robot intercepts all logging and only testcase status showing up on console.

thanks,
Sean

Pekka Klärck

unread,
May 16, 2016, 3:28:34 PM5/16/16
to sea...@gmail.com, robotframework-users
2016-05-13 17:23 GMT+03:00 Sean Wu <sea...@gmail.com>:
> Is there a way to turn on redirect logging to console? by default, robot
> intercepts all logging and only testcase status showing up on console.

There's no built-in way, but you can create a listener with
`log_message` method and redirect all messages where you want. If only
a certain keyword needs to log to the console, you can use
`sys.__stdout__.write` or `robot.api.logger.console` methods.

[1] http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#listener-interface
[2] http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#logging-to-console

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

Sean

unread,
May 17, 2016, 3:38:06 PM5/17/16
to robotframework-users, sea...@gmail.com
Hi peke, 

I was not aware of Listener. Will give it a try.

I do have a wrapper logging method for the keyword implementation. Is that a way to detect whether it's being called by RobotFramework so that it can have extra logging to console enabled?

thanks,
Sean
Reply all
Reply to author
Forward
0 new messages