[O] Split setup_logger

This commit is contained in:
Azalea Gui
2023-03-09 02:45:34 -05:00
parent ba95f80b70
commit c584aea613
4 changed files with 5 additions and 25 deletions
+2 -2
View File
@@ -2,10 +2,10 @@ import asyncio
import telnetlib3
from telnetlib3 import TelnetReaderUnicode, TelnetWriterUnicode
from hypy_utils.logging_utils import setup_logger
from tngame.utils import setup_logger
log = setup_logger(True)
log = setup_logger()
async def shell(reader: TelnetReaderUnicode, writer: TelnetWriterUnicode):
+1
View File
@@ -1,5 +1,6 @@
telnetlib3
hyfetch
hypy_utils>=1.0.18
rich
watchdog
numpy
+2 -1
View File
@@ -8,10 +8,11 @@ import numba
import numpy as np
import telnetlib3
from hyfetch.color_util import RGB
from hypy_utils.logging_utils import setup_logger
from telnetlib3 import TelnetReaderUnicode, TelnetWriterUnicode
from .cowsay import generate_bubble
from .utils import setup_logger, get_ascii_dimensions
from .utils import get_ascii_dimensions
DEBUG = bool(os.environ.get("DEBUG", False))
log = setup_logger(DEBUG)
-22
View File
@@ -1,28 +1,6 @@
import logging
def setup_logger(debug: bool):
# Try to use rich for pretty printing
try:
from rich.logging import RichHandler
handler = RichHandler(rich_tracebacks=True)
from rich.traceback import install
install(show_locals=True)
except ImportError:
handler = logging.StreamHandler()
# Initialize debug logger
logging.basicConfig(
level="NOTSET" if debug else "INFO",
format="%(message)s",
datefmt="[%X]",
handlers=[handler]
)
return logging.getLogger("a2")
def get_ascii_dimensions(ascii_art: str) -> tuple[int, int]:
"""Get the dimensions of an ASCII art."""
height = ascii_art.count('\n')