diff options
Diffstat (limited to 'bot/exts/core')
| -rw-r--r-- | bot/exts/core/error_handler.py | 10 | ||||
| -rw-r--r-- | bot/exts/core/extensions.py | 4 | ||||
| -rw-r--r-- | bot/exts/core/help.py | 4 | ||||
| -rw-r--r-- | bot/exts/core/internal_eval/_helpers.py | 5 | ||||
| -rw-r--r-- | bot/exts/core/internal_eval/_internal_eval.py | 4 |
5 files changed, 14 insertions, 13 deletions
diff --git a/bot/exts/core/error_handler.py b/bot/exts/core/error_handler.py index 81b923fd..cf116ba0 100644 --- a/bot/exts/core/error_handler.py +++ b/bot/exts/core/error_handler.py @@ -1,10 +1,10 @@ -import logging import math import random from collections.abc import Iterable from discord import Embed, Message from discord.ext import commands +from pydis_core.utils.logging import get_logger from sentry_sdk import push_scope from bot.bot import Bot @@ -13,7 +13,7 @@ from bot.utils.commands import get_command_suggestions from bot.utils.decorators import InChannelCheckFailure, InMonthCheckFailure from bot.utils.exceptions import APIError, MovedCommandError, UserNotPlayingError -log = logging.getLogger(__name__) +log = get_logger(__name__) DELETE_DELAY = 10 @@ -32,7 +32,7 @@ class CommandErrorHandler(commands.Cog): if command._buckets.valid: bucket = command._buckets.get_bucket(message) bucket._tokens = min(bucket.rate, bucket._tokens + 1) - logging.debug("Cooldown counter reverted as the command was not used correctly.") + log.debug("Cooldown counter reverted as the command was not used correctly.") @staticmethod def error_embed(message: str, title: Iterable | str = ERROR_REPLIES) -> Embed: @@ -49,7 +49,7 @@ class CommandErrorHandler(commands.Cog): async def on_command_error(self, ctx: commands.Context, error: commands.CommandError) -> None: """Activates when a command raises an error.""" if getattr(error, "handled", False): - logging.debug(f"Command {ctx.command} had its error already handled locally; ignoring.") + log.debug(f"Command {ctx.command} had its error already handled locally; ignoring.") return parent_command = "" @@ -58,7 +58,7 @@ class CommandErrorHandler(commands.Cog): ctx = subctx error = getattr(error, "original", error) - logging.debug( + log.debug( f"Error Encountered: {type(error).__name__} - {error!s}, " f"Command: {ctx.command}, " f"Author: {ctx.author}, " diff --git a/bot/exts/core/extensions.py b/bot/exts/core/extensions.py index f96b0292..cfba58c8 100644 --- a/bot/exts/core/extensions.py +++ b/bot/exts/core/extensions.py @@ -1,5 +1,4 @@ import functools -import logging from collections.abc import Mapping from enum import Enum @@ -7,6 +6,7 @@ from discord import Colour, Embed from discord.ext import commands from discord.ext.commands import Context, group from pydis_core.utils._extensions import unqualify +from pydis_core.utils.logging import get_logger from bot import exts from bot.bot import Bot @@ -14,7 +14,7 @@ from bot.constants import Client, Emojis, MODERATION_ROLES, Roles from bot.utils.checks import with_role_check from bot.utils.pagination import LinePaginator -log = logging.getLogger(__name__) +log = get_logger(__name__) UNLOAD_BLACKLIST = {f"{exts.__name__}.core.extensions"} diff --git a/bot/exts/core/help.py b/bot/exts/core/help.py index 9f96a333..7721d200 100644 --- a/bot/exts/core/help.py +++ b/bot/exts/core/help.py @@ -1,13 +1,13 @@ # Help command from Python bot. All commands that will be added to there in futures should be added to here too. import asyncio import itertools -import logging from contextlib import suppress from typing import NamedTuple from discord import Colour, Embed, HTTPException, Message, Reaction, User from discord.ext import commands from discord.ext.commands import CheckFailure, Cog as DiscordCog, Command, Context +from pydis_core.utils.logging import get_logger from bot import constants from bot.bot import Bot @@ -35,7 +35,7 @@ class Cog(NamedTuple): commands: list[Command] -log = logging.getLogger(__name__) +log = get_logger(__name__) class HelpQueryNotFoundError(ValueError): diff --git a/bot/exts/core/internal_eval/_helpers.py b/bot/exts/core/internal_eval/_helpers.py index 30c4b11c..766f1160 100644 --- a/bot/exts/core/internal_eval/_helpers.py +++ b/bot/exts/core/internal_eval/_helpers.py @@ -4,13 +4,14 @@ import contextlib import functools import inspect import io -import logging import sys import traceback import types from typing import Any -log = logging.getLogger(__name__) +from pydis_core.utils.logging import get_logger + +log = get_logger(__name__) # A type alias to annotate the tuples returned from `sys.exc_info()` ExcInfo = tuple[type[Exception], Exception, types.TracebackType] diff --git a/bot/exts/core/internal_eval/_internal_eval.py b/bot/exts/core/internal_eval/_internal_eval.py index 1ae3c043..39ce558a 100644 --- a/bot/exts/core/internal_eval/_internal_eval.py +++ b/bot/exts/core/internal_eval/_internal_eval.py @@ -1,9 +1,9 @@ -import logging import re import textwrap import discord from discord.ext import commands +from pydis_core.utils.logging import get_logger from bot.bot import Bot from bot.constants import Client, Roles @@ -13,7 +13,7 @@ from ._helpers import EvalContext __all__ = ["InternalEval"] -log = logging.getLogger(__name__) +log = get_logger(__name__) FORMATTED_CODE_REGEX = re.compile( r"(?P<delim>(?P<block>```)|``?)" # code delimiter: 1-3 backticks; (?P=block) only matches if it's a block |