mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-22 08:44:10 +00:00
Add root_logger setting to Client.run
This allows people one way to use the colour logger globally
This commit is contained in:
parent
f12cdd5f90
commit
7be0779b65
@ -810,6 +810,7 @@ class Client:
|
||||
log_handler: Optional[logging.Handler] = MISSING,
|
||||
log_formatter: logging.Formatter = MISSING,
|
||||
log_level: int = MISSING,
|
||||
root_logger: bool = False,
|
||||
) -> None:
|
||||
"""A blocking call that abstracts away the event loop
|
||||
initialisation from you.
|
||||
@ -861,6 +862,14 @@ class Client:
|
||||
only controls the library's log level. To control the root logger's level,
|
||||
you can use ``logging.getLogger().setLevel(level)``.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
root_logger: :class:`bool`
|
||||
Whether to set up the root logger rather than the library logger.
|
||||
By default, only the library logger (``'discord'``) is set up. If this
|
||||
is set to ``True`` then the root logger is set up as well.
|
||||
|
||||
Defaults to ``False``.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
"""
|
||||
|
||||
@ -890,6 +899,11 @@ class Client:
|
||||
logger.setLevel(log_level)
|
||||
logger.addHandler(log_handler)
|
||||
|
||||
if root_logger:
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(log_level)
|
||||
logger.addHandler(log_handler)
|
||||
|
||||
try:
|
||||
asyncio.run(runner())
|
||||
except KeyboardInterrupt:
|
||||
|
Loading…
x
Reference in New Issue
Block a user