Skip to content

Commit 459d5eb

Browse files
authored
DOC add documentation on how to disable the transport logs (#183)
1 parent c17959c commit 459d5eb

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

docs/advanced/logging.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,31 @@ For even more logs, you can set the loglevel at **DEBUG**:
1818
import logging
1919
logging.basicConfig(level=logging.DEBUG)
2020
21+
Disabling logs
22+
--------------
23+
24+
By default, the logs for the transports are quite verbose.
25+
26+
On the **INFO** level, all the messages between the frontend and the backend are logged which can
27+
be difficult to read especially when it fetches the schema from the transport.
28+
29+
It is possible to disable the logs only for a specific gql transport by setting a higher
30+
log level for this transport (**WARNING** for example) so that the other logs of your program are not affected.
31+
32+
For this, you should import the logger from the transport file and set the level on this logger.
33+
34+
For the RequestsHTTPTransport:
35+
36+
.. code-block:: python
37+
38+
from gql.transport.requests import log as requests_logger
39+
requests_logger.setLevel(logging.WARNING)
40+
41+
For the WebsocketsTransport:
42+
43+
.. code-block:: python
44+
45+
from gql.transport.websockets import log as websockets_logger
46+
websockets_logger.setLevel(logging.WARNING)
47+
2148
.. _logging: https://docs.python.org/3/howto/logging.html

0 commit comments

Comments
 (0)