Skip to content

Commit

Permalink
fix: remove uninit logger from BaseCmds, replace only usage with actu…
Browse files Browse the repository at this point in the history
…ally init logger
  • Loading branch information
Borketh committed Feb 12, 2025
1 parent 064f0ee commit 485a249
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 4 additions & 2 deletions fred/fred_commands/_command_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

from regex import ENHANCEMATCH, match, escape

from ._baseclass import BaseCmds
from ..config import Commands, Crashes, Misc
from ..libraries.common import new_logger

logger = new_logger("[Command/Crash Search]")


def search(table: Type[Commands | Crashes], pattern: str, column: str, force_fuzzy: bool) -> (str | list[str], bool):
Expand All @@ -21,7 +23,7 @@ def search(table: Type[Commands | Crashes], pattern: str, column: str, force_fuz
for item in table.fetch_all()
if (item.get(column, None) is not None) and match(fuzzy_pattern, item[column], flags=ENHANCEMATCH)
]
BaseCmds.logger.info(fuzzies)
logger.info(fuzzies)
return fuzzies[:5], False


Expand Down
2 changes: 0 additions & 2 deletions fred/libraries/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ def new_logger(name: str) -> logging.Logger:

class FredCog(commands.Cog):
bot: Bot = ... # we can assume any cog will have a bot by the time it needs to be accessed
logger: logging.Logger = ...

def __init__(self, bot: Bot):
self.__class__.bot = bot
self.bot = bot
self.logger = new_logger(self.__class__.__name__)
self.__class__.logger = self.logger
self.logger.debug("Cog loaded.")


Expand Down

0 comments on commit 485a249

Please sign in to comment.