Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update Docker and CI #2432

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove checks for request usage.
Something weird was going on where this was raising errors, even with no modifications to the code.
BabyBoySnow authored and pythoninthegrass committed Oct 18, 2024
commit fd5c197645ffdf614d453697628d5319d5f02cb4
63 changes: 62 additions & 1 deletion musicbot/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,62 @@
# Just empty for now...
import sys
import inspect
import logging
from .bot import MusicBot
from .constructs import BetterLogRecord

__all__ = ["MusicBot"]

logging.setLogRecordFactory(BetterLogRecord)

_func_prototype = (
"def {logger_func_name}(self, message, *args, **kwargs):\n"
" if self.isEnabledFor({levelname}):\n"
" self._log({levelname}, message, args, **kwargs)"
)


def _add_logger_level(levelname, level, *, func_name=None):
"""
:type levelname: str
The reference name of the level, e.g. DEBUG, WARNING, etc
:type level: int
Numeric logging level
:type func_name: str
The name of the logger function to log to a level, e.g. "info" for log.info(...)
"""

func_name = func_name or levelname.lower()

setattr(logging, levelname, level)
logging.addLevelName(level, levelname)

exec(
_func_prototype.format(logger_func_name=func_name, levelname=levelname),
logging.__dict__,
locals(),
)
setattr(logging.Logger, func_name, eval(func_name))


_add_logger_level("EVERYTHING", 1)
_add_logger_level("NOISY", 4, func_name="noise")
_add_logger_level("FFMPEG", 5)
_add_logger_level("VOICEDEBUG", 6)

log = logging.getLogger(__name__)
log.setLevel(logging.EVERYTHING)

fhandler = logging.FileHandler(filename="logs/musicbot.log", encoding="utf-8", mode="a")
fhandler.setFormatter(
logging.Formatter(
"[{relativeCreated:.16f}] {asctime} - {levelname} - {name} | "
"In {filename}::{threadName}({thread}), line {lineno} in {funcName}: {message}",
style="{",
)
)
log.addHandler(fhandler)

del _func_prototype
del _add_logger_level
del fhandler