Robot api logger - log python variable type

Hello everyone,

I am trying to improve logging in our Python libraries used in RF tests. I’d love to log not only the value of a variable but also its type. I am trying to do it this way:

from robot.api import logger

logger.debug("my_variable - value: " + str(my_variable), html=True)
logger.debug("my_variable - type: " + str(type(my_variable)), html=True)

But the logging of the type shows as "my variable - type: " in the html log.
Do you have any idea why and how to successfully log the variable type from a python lib?

Thank you
David

str(type(int)) returns a string <class 'int'> which your browser thinks is a html element and thats why it doesn’t show correctly…

You can use type(x).__name__ instead of str(type(int)) … That should work.

2 Likes

Wonderful! Thank you very much for you advice, rasjani.

David

1 Like