[Core] Rich logging for not so rich people (#4577)

* Pop stash

* add rich to setup

* Added forceful enabling of rich logging

* revert some unintended pushed

* Fix possible unbound var
Fix possible 0 members w/out members intent

* One day I won't forget to do style passes

* So this is a thing apperently...

* Bump rich to 9.5.1

* Lock secondary deps

* Different stuff, see the full commit description for more info

- Change few things from print to log.info
- put the log handlers on the root logger instead of individual loggers
- capture warnings to a logger

* Modify log handler to show logger name

* Add a Triboolian to force disable rich

* Style checks

* shortened time, added logger name... again.

* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

* Style & linking

* Be or not to be? Whatever man, it's 4:30 in the morning, goto sleep >.<

* Reintroduce outdated message.

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
Kowlin
2020-12-23 05:11:44 +01:00
committed by GitHub
parent afae84fa6b
commit ab80f46d2e
7 changed files with 236 additions and 66 deletions

View File

@@ -29,6 +29,7 @@ from typing import (
overload,
)
from types import MappingProxyType
from rich.console import Console
import discord
from discord.ext import commands as dpy_commands
@@ -221,6 +222,9 @@ class RedBase(
self._deletion_requests: MutableMapping[int, asyncio.Lock] = weakref.WeakValueDictionary()
# Although I see the use of keeping this public, lets rather make it private.
self._rich_console = Console()
def set_help_formatter(self, formatter: commands.help.HelpFormatterABC):
"""
Set's Red's help formatter.
@@ -878,7 +882,7 @@ class RedBase(
packages.insert(0, "permissions")
to_remove = []
print("Loading packages...")
log.info("Loading packages...")
for package in packages:
try:
spec = await self._cog_mgr.find_cog(package)
@@ -901,7 +905,7 @@ class RedBase(
for package in to_remove:
packages.remove(package)
if packages:
print("Loaded packages: " + ", ".join(packages))
log.info("Loaded packages: " + ", ".join(packages))
if self.rpc_enabled:
await self.rpc.initialize(self.rpc_port)