mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-03 08:35:53 +00:00
Change stderr prints to use the logging module instead
This commit is contained in:
@ -42,8 +42,6 @@ from typing import (
|
||||
import aiohttp
|
||||
import discord
|
||||
import inspect
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from collections.abc import Sequence
|
||||
from discord.backoff import ExponentialBackoff
|
||||
@ -536,8 +534,7 @@ class Loop(Generic[LF]):
|
||||
|
||||
async def _error(self, *args: Any) -> None:
|
||||
exception: Exception = args[-1]
|
||||
print(f'Unhandled exception in internal background task {self.coro.__name__!r}.', file=sys.stderr)
|
||||
traceback.print_exception(type(exception), exception, exception.__traceback__, file=sys.stderr)
|
||||
_log.error('Unhandled exception in internal background task %r.', self.coro.__name__, exc_info=exception)
|
||||
|
||||
def before_loop(self, coro: FT) -> FT:
|
||||
"""A decorator that registers a coroutine to be called before the loop starts running.
|
||||
@ -600,11 +597,15 @@ class Loop(Generic[LF]):
|
||||
|
||||
The coroutine must take only one argument the exception raised (except ``self`` in a class context).
|
||||
|
||||
By default this prints to :data:`sys.stderr` however it could be
|
||||
By default this logs to the library logger however it could be
|
||||
overridden to have a different implementation.
|
||||
|
||||
.. versionadded:: 1.4
|
||||
|
||||
.. versionchanged:: 2.0
|
||||
|
||||
Instead of writing to ``sys.stderr``, the library's logger is used.
|
||||
|
||||
Parameters
|
||||
------------
|
||||
coro: :ref:`coroutine <coroutine>`
|
||||
|
Reference in New Issue
Block a user