From 6c4eb0baf4d38c73a570c52d7a1204d1d8643f3c Mon Sep 17 00:00:00 2001 From: Hanusz Leszek Date: Sat, 12 Dec 2020 12:38:54 +0100 Subject: [PATCH] DOC add documentation on how to disable the transport logs --- docs/advanced/logging.rst | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/advanced/logging.rst b/docs/advanced/logging.rst index 573a83be..7856fa8b 100644 --- a/docs/advanced/logging.rst +++ b/docs/advanced/logging.rst @@ -18,4 +18,31 @@ For even more logs, you can set the loglevel at **DEBUG**: import logging logging.basicConfig(level=logging.DEBUG) +Disabling logs +-------------- + +By default, the logs for the transports are quite verbose. + +On the **INFO** level, all the messages between the frontend and the backend are logged which can +be difficult to read especially when it fetches the schema from the transport. + +It is possible to disable the logs only for a specific gql transport by setting a higher +log level for this transport (**WARNING** for example) so that the other logs of your program are not affected. + +For this, you should import the logger from the transport file and set the level on this logger. + +For the RequestsHTTPTransport: + +.. code-block:: python + + from gql.transport.requests import log as requests_logger + requests_logger.setLevel(logging.WARNING) + +For the WebsocketsTransport: + +.. code-block:: python + + from gql.transport.websockets import log as websockets_logger + websockets_logger.setLevel(logging.WARNING) + .. _logging: https://docs.python.org/3/howto/logging.html