Debian Codegraph @

docs/howto/debugging.rst

raw
1 Enable debug logs
2 ==================
3
4 websockets logs events with the :mod:`logging` module from the standard library.
5
6 It emits logs in the ``"websockets.server"`` and ``"websockets.client"``
7 loggers.
8
9 You can enable logs at the ``DEBUG`` level to see exactly what websockets does.
10
11 If logging isn't configured in your application::
12
13 import logging
14
15 logging.basicConfig(
16 format="%(asctime)s %(message)s",
17 level=logging.DEBUG,
18 )
19
20 If logging is already configured::
21
22 import logging
23
24 logger = logging.getLogger("websockets")
25 logger.setLevel(logging.DEBUG)
26 logger.addHandler(logging.StreamHandler())
27
28 Refer to the :doc:`logging guide <../topics/logging>` for more information about
29 logging in websockets.
30
31 You may also enable asyncio's `debug mode`_ to get warnings about classic
32 pitfalls.
33
34 .. _debug mode: https://docs.python.org/3/library/asyncio-dev.html#asyncio-debug-mode