This helper module is indented to be used by Robot Framework test libraries that run keywords in background using threads and that want those threads to be able to log. By default, as explained in Robot Framework User Guide, messages logged by threads using the programmatic APIs are ignored, and results of logging using the standard output are undefined.
This module provides a custom logger that works mostly like the standard robot.api.logger, but also stores messages logged by background threads. It also provides a method the main thread can use to forward the logged messages to Robot Framework’s log.
Robot Background Logger is hosted in Github and downloads can be found from PYPI. Installation is easiest done with pip:
pip install robotbackgroundlogger
Starting from version 1.2 this module support both Python 2 and Python 3.
Usage
The logger can be taken into use like this:
from robotbackgroundlogger import BackgroundLogger
logger = BackgroundLogger()
After that logger can be used mostly like robot.api.logger:
logger.debug('Hello, world!')
logger.info('<b>HTML</b> example', html=True)
When used by the main thread, messages will be logged immediately exactly like
with robot.api.logger. When used by other threads, messages will be stored
internally. They can be later logged by the main thread by running:
logger.log_background_messages()
If you want to log only messages logged by a certain thread, you can use pass the name of the thread as an argument:
logger.log_background_messages('Example thread')
Logged messages are also removed from the internal message storage. It is possible to do that also without logging:
# Remove all messages
logger.reset_background_messages()
# Remove messages logged by the named thread
logger.reset_background_messages('Another thread')
Example
example.py library that is used by example.robot shows how this module can be used in practice. You can run the example like:
pybot example.robot
Metadata
Release files for robotbackgroundlogger 1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| robotbackgroundlogger-1.2.tar.gz | 3.9 kB | Details |
Release files / robotbackgroundlogger-1.2.tar.gz
| Download URL | robotbackgroundlogger-1.2.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
581be5c9d52d502c10c1548304afad849daf99eb057f26148d4de59b86941e12
|
|
BLAKE2b-256 checksum How to use checksums |
ffd53f44fccb418e5e111fd819f5f3cd62f9950f406b50557129f76e064efd7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |