Skip to content

Commit

Permalink
update logging
Browse files Browse the repository at this point in the history
  • Loading branch information
brad90four committed Feb 24, 2022
1 parent 7584279 commit 15852ba
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
4 changes: 3 additions & 1 deletion bot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from bot.log import log

try:
from dotenv import load_dotenv
print("Found .env file, loading environment variables from it.")
log.debug("Found .env file, loading environment variables from it.")
load_dotenv(override=True)
except ModuleNotFoundError:
pass
5 changes: 0 additions & 5 deletions bot/__main__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import logging

from bot.bot import bot
from bot.constants import Client

log = logging.getLogger(__name__)


bot.load_extension("bot.exts.ping")

bot.run(Client.token)
6 changes: 1 addition & 5 deletions bot/bot.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import logging

from disnake.ext import commands

from bot import constants

log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)
from bot.log import log


class SirRobin(commands.Bot):
Expand Down
3 changes: 0 additions & 3 deletions bot/constants.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import logging
from os import environ
from typing import NamedTuple

log = logging.getLogger(__name__)


class Channels(NamedTuple):
advent_of_code = int(environ.get("AOC_CHANNEL_ID", 897932085766004786))
Expand Down
14 changes: 10 additions & 4 deletions bot/exts/ping.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import logging
# import logging

from disnake import Embed
from disnake.ext import commands

from bot.bot import SirRobin
from bot.log import log

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
# log = logging.getLogger(__name__)
# log.setLevel(logging.DEBUG)
# ch = logging.StreamHandler()
# ch.setLevel(logging.DEBUG)
# format_string = logging.Formatter("%(asctime)s | %(name)s | %(levelname)s | %(message)s")
# ch.setFormatter(format_string)
# log.addHandler(ch)


class Ping(commands.Cog):
Expand All @@ -18,7 +24,7 @@ def __init__(self, bot: SirRobin):
@commands.command(name="ping")
async def ping(self, ctx: commands.Context) -> None:
"""Ping the bot to see its latency and state."""
logger.debug(f"Command `{ctx.invoked_with}` used by {ctx.author}.")
log.debug(f"Command `{ctx.invoked_with}` used by {ctx.author}.")
embed = Embed(
title=":ping_pong: Pong!",
description=f"Gateway Latency: {round(self.bot.latency * 1000)}ms",
Expand Down

0 comments on commit 15852ba

Please sign in to comment.