Add utils.setup_logging to help set up logging outside of Client.run

This commit is contained in:
Rapptz
2022-08-17 22:13:01 -04:00
parent 1c7747fe9d
commit 2bf2bfc9b4
5 changed files with 139 additions and 89 deletions

View File

@ -43,6 +43,17 @@ Likewise, configuring the log level to ``logging.DEBUG`` is also possible:
This is recommended, especially at verbose levels such as ``DEBUG``, as there are a lot of events logged and it would clog the stderr of your program.
If you want to setup logging using the library provided configuration without using :meth:`Client.run`, you can use :func:`discord.utils.setup_logging`:
.. code-block:: python3
import discord
discord.utils.setup_logging()
# or, for example
discord.utils.setup_logging(level=logging.INFO, root=False)
More advanced setups are possible with the :mod:`logging` module. The example below configures a rotating file handler that outputs DEBUG output for everything the library outputs, except for HTTP requests:
.. code-block:: python3