mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-10-22 16:32:59 +00:00
Change stderr prints to use the logging module instead
This commit is contained in:
13
docs/api.rst
13
docs/api.rst
@@ -195,7 +195,7 @@ overriding the specific events. For example: ::
|
||||
|
||||
|
||||
If an event handler raises an exception, :func:`on_error` will be called
|
||||
to handle it, which defaults to print a traceback and ignoring the exception.
|
||||
to handle it, which defaults to logging the traceback and ignoring the exception.
|
||||
|
||||
.. warning::
|
||||
|
||||
@@ -350,7 +350,7 @@ Debug
|
||||
.. function:: on_error(event, *args, **kwargs)
|
||||
|
||||
Usually when an event raises an uncaught exception, a traceback is
|
||||
printed to stderr and the exception is ignored. If you want to
|
||||
logged to stderr and the exception is ignored. If you want to
|
||||
change this behaviour and handle the exception for whatever reason
|
||||
yourself, this event can be overridden. Which, when done, will
|
||||
suppress the default action of printing the traceback.
|
||||
@@ -358,11 +358,6 @@ Debug
|
||||
The information of the exception raised and the exception itself can
|
||||
be retrieved with a standard call to :func:`sys.exc_info`.
|
||||
|
||||
If you want exception to propagate out of the :class:`Client` class
|
||||
you can define an ``on_error`` handler consisting of a single empty
|
||||
:ref:`raise statement <py:raise>`. Exceptions raised by ``on_error`` will not be
|
||||
handled in any way by :class:`Client`.
|
||||
|
||||
.. note::
|
||||
|
||||
``on_error`` will only be dispatched to :meth:`Client.event`.
|
||||
@@ -371,6 +366,10 @@ Debug
|
||||
:ref:`ext_commands_api_bot` listeners such as
|
||||
:meth:`~ext.commands.Bot.listen` or :meth:`~ext.commands.Cog.listener`.
|
||||
|
||||
.. versionchanged:: 2.0
|
||||
|
||||
The traceback is now logged rather than printed.
|
||||
|
||||
:param event: The name of the event that raised the exception.
|
||||
:type event: :class:`str`
|
||||
|
||||
|
@@ -933,6 +933,17 @@ The following methods have been changed:
|
||||
- :meth:`Webhook.send`
|
||||
- :meth:`abc.GuildChannel.set_permissions`
|
||||
|
||||
Logging Changes
|
||||
----------------
|
||||
|
||||
The library now provides a default logging configuration if using :meth:`Client.run`. To disable it, pass ``None`` to the ``log_handler`` keyword parameter. Since the library now provides a default logging configuration, certain methods were changed to no longer print to :data:`sys.stderr` but use the logger instead:
|
||||
|
||||
- :meth:`Client.on_error`
|
||||
- :meth:`discord.ext.tasks.Loop.error`
|
||||
- :meth:`discord.ext.commands.Bot.on_command_error`
|
||||
|
||||
For more information, check :doc:`logging`.
|
||||
|
||||
Removal of ``StoreChannel``
|
||||
-----------------------------
|
||||
|
||||
|
Reference in New Issue
Block a user