What's the proper way to log error messages when using the Robot logging API?

872 views
Skip to first unread message

Rob Ots

unread,
Jun 7, 2013, 5:48:27 PM6/7/13
to robotframe...@googlegroups.com
I was previously using the Python standard logging module, and doing logging.error('Error X occurred.')
 
I decided to try the Robot logging API and found that there is logger.warn|debug|trace|info(), but there is no error() method as there is in the Python logging module. Why is that, and what is the proper way to log error messages when using the logger API?

Kevin O.

unread,
Jun 7, 2013, 10:30:59 PM6/7/13
to robotframe...@googlegroups.com
Both levels warning and error in the Python logging module are mapped to RF's WARN level.
When you are intentionally communicating with a testing framework, anything worse than a warning should cause a failure -- in other words raise an exception, causing the keyword to fail. At least this is what I think the creators were thinking.

Kevin

Pekka Klärck

unread,
Jun 12, 2013, 2:23:13 AM6/12/13
to korm...@gmail.com, robotframe...@googlegroups.com
2013/6/8 Kevin O. <korm...@gmail.com>:
Exactly.

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

Rob Ots

unread,
Jun 12, 2013, 6:18:31 PM6/12/13
to robotframe...@googlegroups.com, korm...@gmail.com
Ok, thanks. I wish there was the flexibility of a logger.error() function to output messages that are prefixed by ERROR in red in the log report (and for the Python logging module's error() to produce the same instead of getting converted into a WARNING in yellow.) Often errors are detected while iterating through a large collection, and it would be nice to be able to simply log the errors as they are encountered, with the prefix ERROR in red and individual timestamps. Ideally the error messages would also be seen in the console as they are found, with ERROR in red. If messages can only be logged as errors by raising an exception, then I guess the multiple error messages have to be stored into a temporary buffer and only get logged all in one shot at the end, under one timestamp, and one label FAIL in red.
 
Reply all
Reply to author
Forward
0 new messages