feat(logging): Add locale to log info.
This commit is contained in:
@@ -13,6 +13,7 @@ from aiohttp import ClientSession
|
||||
from data import Database
|
||||
from utils.lib import tabulate
|
||||
from gui.errors import RenderingException
|
||||
from babel.translator import ctx_locale
|
||||
|
||||
from .config import Conf
|
||||
from .logger import logging_context, log_context, log_action_stack, log_wrap, set_logging_context
|
||||
@@ -236,6 +237,7 @@ class LionBot(Bot):
|
||||
details['cmd'] = f"`{ctx.command.qualified_name}`"
|
||||
if ctx.author:
|
||||
details['author'] = f"`{ctx.author.id}` -- `{ctx.author}`"
|
||||
details['locale'] = f"`{ctx_locale.get()}`"
|
||||
if ctx.guild:
|
||||
details['guild'] = f"`{ctx.guild.id}` -- `{ctx.guild.name}`"
|
||||
details['my_guild_perms'] = f"`{ctx.guild.me.guild_permissions.value}`"
|
||||
|
||||
@@ -6,6 +6,7 @@ from typing import Optional, TYPE_CHECKING
|
||||
import discord
|
||||
from discord.enums import ChannelType
|
||||
from discord.ext.commands import Context
|
||||
from babel.translator import ctx_locale
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .LionBot import LionBot
|
||||
@@ -79,6 +80,7 @@ class LionContext(Context['LionBot']):
|
||||
parts['alias'] = f"\"{self.invoked_with}\""
|
||||
if self.command_failed:
|
||||
parts['failed'] = self.command_failed
|
||||
parts['locale'] = f"\"{ctx_locale.get()}\""
|
||||
|
||||
return "<LionContext: {}>".format(
|
||||
' '.join(f"{name}={value}" for name, value in parts.items())
|
||||
|
||||
@@ -9,6 +9,7 @@ from discord.app_commands.namespace import Namespace
|
||||
|
||||
from utils.lib import tabulate
|
||||
from gui.errors import RenderingException
|
||||
from babel.translator import ctx_locale
|
||||
|
||||
from .logger import logging_context, set_logging_context, log_wrap, log_action_stack
|
||||
from .errors import SafeCancellation
|
||||
@@ -76,6 +77,7 @@ class LionTree(CommandTree):
|
||||
details['interactiontype'] = f"`{interaction.type}`"
|
||||
if interaction.command:
|
||||
details['cmd'] = f"`{interaction.command.qualified_name}`"
|
||||
details['locale'] = f"`{ctx_locale.get()}`"
|
||||
if interaction.user:
|
||||
details['user'] = f"`{interaction.user.id}` -- `{interaction.user}`"
|
||||
if interaction.guild:
|
||||
|
||||
Reference in New Issue
Block a user