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

Add support for Robot's programmatic logging APIs #27

Closed
mulmschneider opened this issue Jul 31, 2015 · 2 comments
Closed

Add support for Robot's programmatic logging APIs #27

mulmschneider opened this issue Jul 31, 2015 · 2 comments

Comments

@mulmschneider
Copy link

As far as I can tell, the way how logging works in combination with the PythonRemoteServer depends very much on when the corresponding logging StreamHandler is first created.
If it is created before _intercept_std_streams() is called, then the logging output will be sent to stderr of the server. If it is created after _intercept_std_streams(), then the output is sent as output to the calling client.

I fixed this for my use case with this change to _intercept_std_streams(), which makes sure that I receive all log messages logged during run_keyword() on the robotframework client:

    def _intercept_std_streams(self):
        sys.stdout = StringIO()
        sys.stderr = StringIO()
        # reset the logging handler so that it is connected to the right stderr stream
        import logging
        logging.getLogger().handlers = []
        ch = logging.StreamHandler()
        logging.getLogger().addHandler(ch)

NOTE: I mostly opened this issue so that it is documented in case other people run into similiar problems. I'm not sure if this is something that can/should be handled by the default implementation of PythonRemoteServer, since you would have to consider a myriad of possible python logging configurations. Feel free to close.

@pekkaklarck
Copy link
Member

Yeah, the remote server only supports logging via stdout/stderr. Some kind of support for Robot's own robot.api.logger API and Python's standard logging module would be nice.

@pekkaklarck pekkaklarck changed the title _intercept_std_streams() does not play nice with python/robotframework logging Add support for Robot's programmatic logging APIs Jan 9, 2017
@pekkaklarck
Copy link
Member

Oh, #26 proposes the exact same thing. Closing this as a duplicate.

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

2 participants