Skip to content

Commit ef65cce

Browse files
authored
Merge pull request #12 from krasoffski/examplefix
Fix logging example, make it ready to copy-paste.
2 parents 134e617 + ce82ea7 commit ef65cce

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

README.rst

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,28 @@ logging handler privided by plugin like bellow:
5959

6060
.. code-block:: python
6161
62-
# Import Report Portal handler in the test module.
62+
import logging
63+
# Import Report Portal handler to the test module.
6364
from pytest_reportportal import RPlogHandler
64-
# Get logger.
65-
logger = logging.getLogger()
66-
# Create hanler, set log level add it to the logger.
65+
# Setting up a logging.
66+
logger = logging.getLogger(__name__)
67+
logger.setLevel(logging.DEBUG)
68+
# Create handler for Report Portal.
6769
rp_handler = RPlogHandler()
70+
# Set INFO level for Report Portal handler.
6871
rp_handler.setLevel(logging.INFO)
72+
# Add handler to the logger.
6973
logger.addHandler(rp_handler)
74+
75+
7076
# In this case only INFO messages will be sent to the Report Portal.
71-
def test_one(self):
77+
def test_one():
7278
logger.info("Case1. Step1")
7379
x = "this"
74-
logger.info("Case1. Step2")
80+
logger.info("x is: %s", x)
7581
assert 'h' in x
82+
# This debug message will not be sent to the Report Portal.
83+
logger.debug("Case1. Debug message")
7684
7785
7886
Launching

0 commit comments

Comments
 (0)