Skip to content

DOC add documentation on how to disable the transport logs #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions docs/advanced/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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