From c584aea613215e6b8c14dea059e4d854accbe189 Mon Sep 17 00:00:00 2001 From: Azalea Gui Date: Thu, 9 Mar 2023 02:45:34 -0500 Subject: [PATCH] [O] Split setup_logger --- relay.py | 4 ++-- requirements.txt | 1 + tngame/telnet.py | 3 ++- tngame/utils.py | 22 ---------------------- 4 files changed, 5 insertions(+), 25 deletions(-) diff --git a/relay.py b/relay.py index 2820c75..feb9f3d 100644 --- a/relay.py +++ b/relay.py @@ -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): diff --git a/requirements.txt b/requirements.txt index e4b3586..0683efb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ telnetlib3 hyfetch +hypy_utils>=1.0.18 rich watchdog numpy diff --git a/tngame/telnet.py b/tngame/telnet.py index b26c747..85ce647 100644 --- a/tngame/telnet.py +++ b/tngame/telnet.py @@ -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) diff --git a/tngame/utils.py b/tngame/utils.py index 86185d8..f4aa0ec 100644 --- a/tngame/utils.py +++ b/tngame/utils.py @@ -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')