📝Logging
How to use Pylenium's built-in logger
Pylenium includes two custom Log Levels and a global Logger instance that you can use.
Log Levels
Name | Level | Note |
---|---|---|
CRITICAL | 50 | |
ERROR | 40 | |
WARNING | 30 | |
USER | 25 | Custom |
INFO | 20 | Default |
COMMAND | 15 | Custom |
DEBUG | 10 |
If you are familiar with logging, then the above table is straightforward. If not, then all you really need to know about these levels is that you can set the Log Level when executing tests, and any logs at the specified level or higher will be captured.
For example, if you wanted to set the Log Level to see only logs at INFO
and higher, you would do this:
The above command would ignore logs below the INFO
level. In other words, ignore the COMMAND
and DEBUG
logs.
COMMAND Level
The COMMAND
Log Level is used by Pylenium for logging its commands in a cleaner and easier to parse format. You shouldn't use this level unless you really want to. Take a look at our visit()
command to see it in action:
Notice how the string uses the %s
format and NOT the f-string format.
This is intentional!
USER Level
The USER
Log Level is meant for you! This is a convenient way for logging things if you don't want everything from the INFO
level.
I highly recommend creating your own loggers, but sometimes something simple like this is all you need 😄
To take advantage of this level, use log.this()
:
You can also directly use py.log
:
Last updated