Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support logging using robot.api.logger and logging APIs #26

Open
vkruoso opened this issue Jul 2, 2015 · 5 comments
Open

Support logging using robot.api.logger and logging APIs #26

vkruoso opened this issue Jul 2, 2015 · 5 comments

Comments

@vkruoso
Copy link

vkruoso commented Jul 2, 2015

It would be a nice feature to have if you could have a library that uses the robot.api.logger to log messages to just work when used in a remote server using the PythonRemoteServer.

@VernonCrabtree
Copy link

I am looking for this 'feature' too. It seems very strange not to support Robots own logging in a Robot server.
I know python "print" output is picked up.
But, as an example, I run the OperatingSystem Copy File keyword, but the INFO message gets lost on the remote system somewhere. This needs to be reported back to the output of the calling script.
I tried registering my own logger in my remote library as follows:
class RFremoteLogger(Logger): # Inherit from robot.output.logger.Logger
def message(self, record):
print record
. . .
if name == 'main':
from robotremoteserver import RobotRemoteServer
LOGGER.register_logger(RFremoteLogger)
RobotRemoteServer(MyRemoteLib(), *sys.argv[1:])

But this didn't work. No error, but also no output. I tried some other variations but no luck.
Any suggestions how to get the output?

@VernonCrabtree
Copy link

For anyone else coming here: I solved it with this bit of code in my remote library:

from robot.api import logger

def remote_log_message(message,level,html=False):
print '{} {}'.format(level, message)

logger.write = remote_log_message

This works because most Robot libraries import logger from robot.api - where we replace the definition of write.

@swordfly
Copy link

swordfly commented Dec 7, 2016

@VernonCrabtree Thank you, it's really a easy and best solution.

@pekkaklarck
Copy link
Member

Yep, official support for robot.api.logger as well as for Python's logging module would be nice.

@pekkaklarck pekkaklarck changed the title Support robot.api.logger when running remote keywords Support logging using robot.api.logger and logging APIs Jan 9, 2017
pekkaklarck added a commit that referenced this issue Jan 10, 2017
- Document that 1.1 supports Python 3.3+ (as well as PyPy). Fixes #17.
- Document that 1.1 supports the dynamic API. Fixes #18.
- Also mention that programmatic logging isn't supported. See #26.
- General enhancements.
@conrados
Copy link

conrados commented Jun 6, 2019

@VernonCrabtree : works like a charm. Nice workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants