Skip to content

Commit

Permalink
feat(logs): add discord logs to beta version
Browse files Browse the repository at this point in the history
  • Loading branch information
ZRunner committed Jan 6, 2024
1 parent e70a305 commit 82e1794
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions libs/boot_utils/logs_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def setup_bot_logger():
"""Create the logger module for the bot, used for logs"""
log = logging.getLogger("runner")
log_format = logging.Formatter("%(asctime)s %(levelname)s: %(message)s", datefmt="[%d/%m/%Y %H:%M:%S]")
log_format = logging.Formatter("[{asctime}] {levelname} {name}: {message}", datefmt="%Y-%m-%d %H:%M:%S", style='{')

# DEBUG logs to a file
file_handler = RotatingFileHandler("logs/debug.log", maxBytes=1e6, backupCount=2, delay=True)
Expand Down Expand Up @@ -47,9 +47,17 @@ def setup_database_logger():
return log

def set_beta_logs():
"Edit the logging level to DEBUG, when the beta bot is used"
log = logging.getLogger("runner")
for handler in log.handlers:
"Edit the logging handlers to be more verbose in console, when the beta bot is used"
# set the console logger to DEBUG
bot_logger = logging.getLogger("runner")
for handler in bot_logger.handlers:
if handler.name == "console":
handler.setLevel(logging.DEBUG)
break
# add discord.py logs to console
discord_logger = logging.getLogger('discord')
discord_logger.setLevel(logging.INFO)
for handler in bot_logger.handlers:
if handler.name == "console":
discord_logger.addHandler(handler)
break

0 comments on commit 82e1794

Please sign in to comment.