Improved config & chnaged logging

This commit is contained in:
Sven Heidemann 2021-11-23 17:23:11 +01:00
parent 1f095c9415
commit 2d261a6222
3 changed files with 54 additions and 50 deletions

View File

@ -9,8 +9,8 @@
"LoggingSettings": { "LoggingSettings": {
"Path": "logs/", "Path": "logs/",
"Filename": "log_dev.log", "Filename": "log_dev.log",
"ConsoleLogLevel": "TRACE", "ConsoleLogLevel": "DEBUG",
"FileLogLevel": "TRACE" "FileLogLevel": "DEBUG"
}, },
"Discord": { "Discord": {

View File

@ -8,8 +8,12 @@
"LoggingSettings": { "LoggingSettings": {
"Path": "logs/", "Path": "logs/",
"Filename": "log_$start_time.log", "Filename": "log_staging_$start_time.log",
"ConsoleLogLevel": "DEBUG", "ConsoleLogLevel": "DEBUG",
"FileLogLevel": "DEBUG" "FileLogLevel": "DEBUG"
},
"Discord": {
"Token": "OTEwMjAxNjA1NDkwNjEwMjA3.YZPZTQ.kvMUuDUH_-qsllgkch8LYmXcKlo"
} }
} }

View File

@ -96,234 +96,234 @@ class ModuleService(ModuleServiceABC, commands.Cog, metaclass=_MetaCogABC):
@commands.Cog.listener() @commands.Cog.listener()
async def on_connect(self): async def on_connect(self):
self._logger.debug(__name__, f'Received on_connect') self._logger.trace(__name__, f'Received on_connect')
await self._handle_event(OnConnectABC) await self._handle_event(OnConnectABC)
@commands.Cog.listener() @commands.Cog.listener()
async def on_disconnect(self): async def on_disconnect(self):
self._logger.debug(__name__, f'Received on_disconnect') self._logger.trace(__name__, f'Received on_disconnect')
await self._handle_event(OnDisconnectABC) await self._handle_event(OnDisconnectABC)
async def on_ready(self): async def on_ready(self):
self._logger.debug(__name__, f'Received on_ready') self._logger.trace(__name__, f'Received on_ready')
await self._handle_event(OnReadyABC) await self._handle_event(OnReadyABC)
@commands.Cog.listener() @commands.Cog.listener()
async def on_resume(self): async def on_resume(self):
self._logger.debug(__name__, f'Received on_resume') self._logger.trace(__name__, f'Received on_resume')
await self._handle_event(OnResumeABC) await self._handle_event(OnResumeABC)
@commands.Cog.listener() @commands.Cog.listener()
async def on_error(self, event: str, *args, **kwargs): async def on_error(self, event: str, *args, **kwargs):
self._logger.debug(__name__, f'Received on_error:\n\t{event}\n\t{args}\n\t{kwargs}') self._logger.trace(__name__, f'Received on_error:\n\t{event}\n\t{args}\n\t{kwargs}')
await self._handle_event(OnReadyABC, event, *args, **kwargs) await self._handle_event(OnReadyABC, event, *args, **kwargs)
@commands.Cog.listener() @commands.Cog.listener()
async def on_typing(self, channel: discord.abc.Messageable, user: Union[discord.User, discord.Member], when: datetime): async def on_typing(self, channel: discord.abc.Messageable, user: Union[discord.User, discord.Member], when: datetime):
self._logger.debug(__name__, f'Received on_typing:\n\t{channel}\n\t{user}\n\t{when}') self._logger.trace(__name__, f'Received on_typing:\n\t{channel}\n\t{user}\n\t{when}')
await self._handle_event(OnTypingABC, channel, user, when) await self._handle_event(OnTypingABC, channel, user, when)
@commands.Cog.listener() @commands.Cog.listener()
async def on_message(self, message: discord.Message): async def on_message(self, message: discord.Message):
self._logger.debug(__name__, f'Received on_message:\n\t{message}\n\t{message.content}') self._logger.trace(__name__, f'Received on_message:\n\t{message}\n\t{message.content}')
await self._handle_event(OnMessageABC, message) await self._handle_event(OnMessageABC, message)
@commands.Cog.listener() @commands.Cog.listener()
async def on_message_delete(self, message: discord.Message): async def on_message_delete(self, message: discord.Message):
self._logger.debug(__name__, f'Received on_message_delete:\n\t{message}\n\t{message.content}') self._logger.trace(__name__, f'Received on_message_delete:\n\t{message}\n\t{message.content}')
await self._handle_event(OnMessageDeleteABC, message) await self._handle_event(OnMessageDeleteABC, message)
@commands.Cog.listener() @commands.Cog.listener()
async def on_bulk_message_delete(self, messages: list[discord.Message]): async def on_bulk_message_delete(self, messages: list[discord.Message]):
self._logger.debug(__name__, f'Received on_bulk_message_delete:\n\t{len(messages)}') self._logger.trace(__name__, f'Received on_bulk_message_delete:\n\t{len(messages)}')
await self._handle_event(OnBulkMessageDeleteABC, messages) await self._handle_event(OnBulkMessageDeleteABC, messages)
@commands.Cog.listener() @commands.Cog.listener()
async def on_message_edit(self, before: discord.Message, after: discord.Message): async def on_message_edit(self, before: discord.Message, after: discord.Message):
self._logger.debug(__name__, f'Received on_message_edit:\n\t{before}\n\t{after}') self._logger.trace(__name__, f'Received on_message_edit:\n\t{before}\n\t{after}')
await self._handle_event(OnMessageEditABC, before, after) await self._handle_event(OnMessageEditABC, before, after)
@commands.Cog.listener() @commands.Cog.listener()
async def on_reaction_add(self, reaction: discord.Reaction, user: discord.User): async def on_reaction_add(self, reaction: discord.Reaction, user: discord.User):
self._logger.debug(__name__, f'Received on_reaction_add:\n\t{reaction}\n\t{user}') self._logger.trace(__name__, f'Received on_reaction_add:\n\t{reaction}\n\t{user}')
await self._handle_event(OnReactionAddABC, reaction, user) await self._handle_event(OnReactionAddABC, reaction, user)
@commands.Cog.listener() @commands.Cog.listener()
async def on_reaction_remove(self, reaction: discord.Reaction, user: discord.User): async def on_reaction_remove(self, reaction: discord.Reaction, user: discord.User):
self._logger.debug(__name__, f'Received on_reaction_remove:\n\t{reaction}\n\t{user}') self._logger.trace(__name__, f'Received on_reaction_remove:\n\t{reaction}\n\t{user}')
await self._handle_event(OnReactionRemoveABC, reaction, user) await self._handle_event(OnReactionRemoveABC, reaction, user)
@commands.Cog.listener() @commands.Cog.listener()
async def on_reaction_clear(self, message: discord.Message, reactions: list[discord.Reaction]): async def on_reaction_clear(self, message: discord.Message, reactions: list[discord.Reaction]):
self._logger.debug(__name__, f'Received on_reaction_reon_reaction_clearmove:\n\t{message}\n\t{len(reactions)}') self._logger.trace(__name__, f'Received on_reaction_reon_reaction_clearmove:\n\t{message}\n\t{len(reactions)}')
await self._handle_event(OnReactionClearABC, message, reactions) await self._handle_event(OnReactionClearABC, message, reactions)
@commands.Cog.listener() @commands.Cog.listener()
async def on_reaction_clear_emoji(self, reaction: discord.Reaction): async def on_reaction_clear_emoji(self, reaction: discord.Reaction):
self._logger.debug(__name__, f'Received on_reaction_clear_emoji:\n\t{reaction}') self._logger.trace(__name__, f'Received on_reaction_clear_emoji:\n\t{reaction}')
await self._handle_event(OnReactionClearEmojiABC, reaction) await self._handle_event(OnReactionClearEmojiABC, reaction)
@commands.Cog.listener() @commands.Cog.listener()
async def on_private_channel_delete(self, channel: discord.abc.PrivateChannel): async def on_private_channel_delete(self, channel: discord.abc.PrivateChannel):
self._logger.debug(__name__, f'Received on_private_channel_delete:\n\t{channel}') self._logger.trace(__name__, f'Received on_private_channel_delete:\n\t{channel}')
await self._handle_event(OnPrivateChannelDeleteABC, channel) await self._handle_event(OnPrivateChannelDeleteABC, channel)
@commands.Cog.listener() @commands.Cog.listener()
async def on_private_channel_create(self, channel: discord.abc.PrivateChannel): async def on_private_channel_create(self, channel: discord.abc.PrivateChannel):
self._logger.debug(__name__, f'Received on_private_channel_create:\n\t{channel}') self._logger.trace(__name__, f'Received on_private_channel_create:\n\t{channel}')
await self._handle_event(OnPrivateChannelCreateABC, channel) await self._handle_event(OnPrivateChannelCreateABC, channel)
@commands.Cog.listener() @commands.Cog.listener()
async def on_private_channel_update(self, before: discord.GroupChannel, after: discord.GroupChannel): async def on_private_channel_update(self, before: discord.GroupChannel, after: discord.GroupChannel):
self._logger.debug(__name__, f'Received on_private_channel_update:\n\t{before}\n\t{after}') self._logger.trace(__name__, f'Received on_private_channel_update:\n\t{before}\n\t{after}')
await self._handle_event(OnPrivateChannelUpdateABC, before, after) await self._handle_event(OnPrivateChannelUpdateABC, before, after)
@commands.Cog.listener() @commands.Cog.listener()
async def on_private_channel_pins_update(self, channel: discord.abc.PrivateChannel, list_pin: Optional[datetime]): async def on_private_channel_pins_update(self, channel: discord.abc.PrivateChannel, list_pin: Optional[datetime]):
self._logger.debug(__name__, f'Received on_private_channel_pins_update:\n\t{channel}\n\t{list_pin}') self._logger.trace(__name__, f'Received on_private_channel_pins_update:\n\t{channel}\n\t{list_pin}')
await self._handle_event(OnPrivateChannelPinsUpdateABC, channel, list_pin) await self._handle_event(OnPrivateChannelPinsUpdateABC, channel, list_pin)
@commands.Cog.listener() @commands.Cog.listener()
async def on_guild_channel_delete(self, channel: discord.abc.GuildChannel): async def on_guild_channel_delete(self, channel: discord.abc.GuildChannel):
self._logger.debug(__name__, f'Received on_guild_channel_delete:\n\t{channel}') self._logger.trace(__name__, f'Received on_guild_channel_delete:\n\t{channel}')
await self._handle_event(OnGuildChannelDeleteABC, channel) await self._handle_event(OnGuildChannelDeleteABC, channel)
@commands.Cog.listener() @commands.Cog.listener()
async def on_guild_channel_create(self, channel: discord.abc.GuildChannel): async def on_guild_channel_create(self, channel: discord.abc.GuildChannel):
self._logger.debug(__name__, f'Received on_guild_channel_create:\n\t{channel}') self._logger.trace(__name__, f'Received on_guild_channel_create:\n\t{channel}')
await self._handle_event(OnGuildChannelCreateABC, channel) await self._handle_event(OnGuildChannelCreateABC, channel)
@commands.Cog.listener() @commands.Cog.listener()
async def on_guild_channel_update(self, before: discord.abc.GuildChannel, after: discord.abc.GuildChannel): async def on_guild_channel_update(self, before: discord.abc.GuildChannel, after: discord.abc.GuildChannel):
self._logger.debug(__name__, f'Received on_guild_channel_update:\n\t{before}\n\t{after}') self._logger.trace(__name__, f'Received on_guild_channel_update:\n\t{before}\n\t{after}')
await self._handle_event(OnGuildChannelUpdateABC, before, after) await self._handle_event(OnGuildChannelUpdateABC, before, after)
@commands.Cog.listener() @commands.Cog.listener()
async def on_guild_channel_pins_update(self, channel: discord.abc.GuildChannel, list_pin: Optional[datetime]): async def on_guild_channel_pins_update(self, channel: discord.abc.GuildChannel, list_pin: Optional[datetime]):
self._logger.debug(__name__, f'Received on_guild_channel_pins_update:\n\t{channel}\n\t{list_pin}') self._logger.trace(__name__, f'Received on_guild_channel_pins_update:\n\t{channel}\n\t{list_pin}')
await self._handle_event(OnGuildChannelPinsUpdateABC, channel, list_pin) await self._handle_event(OnGuildChannelPinsUpdateABC, channel, list_pin)
@commands.Cog.listener() @commands.Cog.listener()
async def on_guild_integrations_update(self, guild: discord.Guild): async def on_guild_integrations_update(self, guild: discord.Guild):
self._logger.debug(__name__, f'Received on_guild_integrations_update:\n\t{guild}') self._logger.trace(__name__, f'Received on_guild_integrations_update:\n\t{guild}')
await self._handle_event(OnGuildIntegrationsUpdateABC, guild) await self._handle_event(OnGuildIntegrationsUpdateABC, guild)
@commands.Cog.listener() @commands.Cog.listener()
async def on_webhooks_update(self, channel: discord.abc.GuildChannel): async def on_webhooks_update(self, channel: discord.abc.GuildChannel):
self._logger.debug(__name__, f'Received on_webhooks_update:\n\t{channel}') self._logger.trace(__name__, f'Received on_webhooks_update:\n\t{channel}')
await self._handle_event(OnWebhooksUpdateABC, channel) await self._handle_event(OnWebhooksUpdateABC, channel)
@commands.Cog.listener() @commands.Cog.listener()
async def on_member_join(self, member: discord.Member): async def on_member_join(self, member: discord.Member):
self._logger.debug(__name__, f'Received on_member_join:\n\t{member}') self._logger.trace(__name__, f'Received on_member_join:\n\t{member}')
await self._handle_event(OnMemberJoinABC, member) await self._handle_event(OnMemberJoinABC, member)
@commands.Cog.listener() @commands.Cog.listener()
async def on_member_remove(self, member: discord.Member): async def on_member_remove(self, member: discord.Member):
self._logger.debug(__name__, f'Received on_member_remove:\n\t{member}') self._logger.trace(__name__, f'Received on_member_remove:\n\t{member}')
await self._handle_event(OnMemberRemoveABC, member) await self._handle_event(OnMemberRemoveABC, member)
@commands.Cog.listener() @commands.Cog.listener()
async def on_member_update(self, before: discord.Member, after: discord.Member): async def on_member_update(self, before: discord.Member, after: discord.Member):
self._logger.debug(__name__, f'Received on_member_update:\n\t{before}\n\t{after}') self._logger.trace(__name__, f'Received on_member_update:\n\t{before}\n\t{after}')
await self._handle_event(OnMemberUpdateABC, before, after) await self._handle_event(OnMemberUpdateABC, before, after)
@commands.Cog.listener() @commands.Cog.listener()
async def on_user_update(self, before: discord.User, after: discord.User): async def on_user_update(self, before: discord.User, after: discord.User):
self._logger.debug(__name__, f'Received on_user_update:\n\t{before}\n\t{after}') self._logger.trace(__name__, f'Received on_user_update:\n\t{before}\n\t{after}')
await self._handle_event(OnUserUpdateABC, before, after) await self._handle_event(OnUserUpdateABC, before, after)
@commands.Cog.listener() @commands.Cog.listener()
async def on_guild_join(self, guild: discord.Guild): async def on_guild_join(self, guild: discord.Guild):
self._logger.debug(__name__, f'Received on_guild_join:\n\t{guild}') self._logger.trace(__name__, f'Received on_guild_join:\n\t{guild}')
await self._handle_event(OnGuildJoinABC, guild) await self._handle_event(OnGuildJoinABC, guild)
@commands.Cog.listener() @commands.Cog.listener()
async def on_guild_remove(self, guild: discord.Guild): async def on_guild_remove(self, guild: discord.Guild):
self._logger.debug(__name__, f'Received on_guild_remove:\n\t{guild}') self._logger.trace(__name__, f'Received on_guild_remove:\n\t{guild}')
await self._handle_event(OnGuildRemoveABC, guild) await self._handle_event(OnGuildRemoveABC, guild)
@commands.Cog.listener() @commands.Cog.listener()
async def on_guild_update(self, before: discord.Guild, after: discord.Guild): async def on_guild_update(self, before: discord.Guild, after: discord.Guild):
self._logger.debug(__name__, f'Received on_guild_update:\n\t{before}\n\t{after}') self._logger.trace(__name__, f'Received on_guild_update:\n\t{before}\n\t{after}')
await self._handle_event(OnGuildUpdateABC, before, after) await self._handle_event(OnGuildUpdateABC, before, after)
@commands.Cog.listener() @commands.Cog.listener()
async def on_guild_role_create(self, role: discord.Role): async def on_guild_role_create(self, role: discord.Role):
self._logger.debug(__name__, f'Received on_guild_role_create:\n\t{role}') self._logger.trace(__name__, f'Received on_guild_role_create:\n\t{role}')
await self._handle_event(OnGuildRoleCreateABC, role) await self._handle_event(OnGuildRoleCreateABC, role)
@commands.Cog.listener() @commands.Cog.listener()
async def on_guild_role_delete(self, role: discord.Role): async def on_guild_role_delete(self, role: discord.Role):
self._logger.debug(__name__, f'Received on_guild_role_delete:\n\t{role}') self._logger.trace(__name__, f'Received on_guild_role_delete:\n\t{role}')
await self._handle_event(OnGuildRoleDeleteABC, role) await self._handle_event(OnGuildRoleDeleteABC, role)
@commands.Cog.listener() @commands.Cog.listener()
async def on_guild_role_update(self, before: discord.Role, after: discord.Role): async def on_guild_role_update(self, before: discord.Role, after: discord.Role):
self._logger.debug(__name__, f'Received on_guild_role_update:\n\t{before}\n\t{after}') self._logger.trace(__name__, f'Received on_guild_role_update:\n\t{before}\n\t{after}')
await self._handle_event(OnGuildRoleUpdateABC, before, after) await self._handle_event(OnGuildRoleUpdateABC, before, after)
@commands.Cog.listener() @commands.Cog.listener()
async def on_guild_emojis_update(self, guild: discord.Guild, before: Sequence[discord.Emoji], after: Sequence[discord.Emoji]): async def on_guild_emojis_update(self, guild: discord.Guild, before: Sequence[discord.Emoji], after: Sequence[discord.Emoji]):
self._logger.debug(__name__, f'Received on_guild_emojis_update:\n\t{guild}\n\t{before}\n\t{after}') self._logger.trace(__name__, f'Received on_guild_emojis_update:\n\t{guild}\n\t{before}\n\t{after}')
await self._handle_event(OnGuildEmojisUpdateABC, guild, before, after) await self._handle_event(OnGuildEmojisUpdateABC, guild, before, after)
@commands.Cog.listener() @commands.Cog.listener()
async def on_guild_available(self, guild: discord.Guild): async def on_guild_available(self, guild: discord.Guild):
self._logger.debug(__name__, f'Received on_guild_available:\n\t{guild}') self._logger.trace(__name__, f'Received on_guild_available:\n\t{guild}')
await self._handle_event(OnGuildAvailableABC, guild) await self._handle_event(OnGuildAvailableABC, guild)
@commands.Cog.listener() @commands.Cog.listener()
async def on_guild_unavailable(self, guild: discord.Guild): async def on_guild_unavailable(self, guild: discord.Guild):
self._logger.debug(__name__, f'Received on_guild_unavailable:\n\t{guild}') self._logger.trace(__name__, f'Received on_guild_unavailable:\n\t{guild}')
await self._handle_event(OnGuildUnavailableABC, guild) await self._handle_event(OnGuildUnavailableABC, guild)
@commands.Cog.listener() @commands.Cog.listener()
async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState): async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState):
self._logger.debug(__name__, f'Received on_voice_state_update:\n\t{member}\n\t{before}\n\t{after}') self._logger.trace(__name__, f'Received on_voice_state_update:\n\t{member}\n\t{before}\n\t{after}')
await self._handle_event(OnVoiceStateUpdateABC, member, before, after) await self._handle_event(OnVoiceStateUpdateABC, member, before, after)
@commands.Cog.listener() @commands.Cog.listener()
async def on_member_ban(self, guild: discord.Guild, user: discord.User): async def on_member_ban(self, guild: discord.Guild, user: discord.User):
self._logger.debug(__name__, f'Received on_member_ban:\n\t{guild}\n\t{user}') self._logger.trace(__name__, f'Received on_member_ban:\n\t{guild}\n\t{user}')
await self._handle_event(OnMemberBanABC, guild, user) await self._handle_event(OnMemberBanABC, guild, user)
@commands.Cog.listener() @commands.Cog.listener()
async def on_member_unban(self, guild: discord.Guild, user: discord.User): async def on_member_unban(self, guild: discord.Guild, user: discord.User):
self._logger.debug(__name__, f'Received on_member_unban:\n\t{guild}\n\t{user}') self._logger.trace(__name__, f'Received on_member_unban:\n\t{guild}\n\t{user}')
await self._handle_event(OnMemberUnbanABC, guild, user) await self._handle_event(OnMemberUnbanABC, guild, user)
@commands.Cog.listener() @commands.Cog.listener()
async def on_invite_create(self, invite: discord.Invite): async def on_invite_create(self, invite: discord.Invite):
self._logger.debug(__name__, f'Received on_invite_create:\n\t{invite}') self._logger.trace(__name__, f'Received on_invite_create:\n\t{invite}')
await self._handle_event(OnInviteCreateABC, invite) await self._handle_event(OnInviteCreateABC, invite)
@commands.Cog.listener() @commands.Cog.listener()
async def on_invite_delete(self, invite: discord.Invite): async def on_invite_delete(self, invite: discord.Invite):
self._logger.debug(__name__, f'Received on_invite_create:\n\t{invite}') self._logger.trace(__name__, f'Received on_invite_create:\n\t{invite}')
await self._handle_event(OnInviteDeleteABC, invite) await self._handle_event(OnInviteDeleteABC, invite)
@commands.Cog.listener() @commands.Cog.listener()
async def on_group_join(self, channel: discord.GroupChannel, user: discord.User): async def on_group_join(self, channel: discord.GroupChannel, user: discord.User):
self._logger.debug(__name__, f'Received on_group_join:\n\t{channel}\n\t{user}') self._logger.trace(__name__, f'Received on_group_join:\n\t{channel}\n\t{user}')
await self._handle_event(OnGroupJoinABC, channel, user) await self._handle_event(OnGroupJoinABC, channel, user)
@commands.Cog.listener() @commands.Cog.listener()
async def on_group_remove(self, channel: discord.GroupChannel, user: discord.User): async def on_group_remove(self, channel: discord.GroupChannel, user: discord.User):
self._logger.debug(__name__, f'Received on_group_remove:\n\t{channel}\n\t{user}') self._logger.trace(__name__, f'Received on_group_remove:\n\t{channel}\n\t{user}')
await self._handle_event(OnGroupRemoveABC, channel, user) await self._handle_event(OnGroupRemoveABC, channel, user)
@commands.Cog.listener() @commands.Cog.listener()
async def on_relationship_add(self, relationship: discord.Relationship): async def on_relationship_add(self, relationship: discord.Relationship):
self._logger.debug(__name__, f'Received on_relationship_add:\n\t{relationship}') self._logger.trace(__name__, f'Received on_relationship_add:\n\t{relationship}')
await self._handle_event(OnRelationshipAddABC, relationship) await self._handle_event(OnRelationshipAddABC, relationship)
@commands.Cog.listener() @commands.Cog.listener()
async def on_relationship_remove(self, relationship: discord.Relationship): async def on_relationship_remove(self, relationship: discord.Relationship):
self._logger.debug(__name__, f'Received on_relationship_remove:\n\t{relationship}') self._logger.trace(__name__, f'Received on_relationship_remove:\n\t{relationship}')
await self._handle_event(OnRelationshipRemoveABC, relationship) await self._handle_event(OnRelationshipRemoveABC, relationship)
@commands.Cog.listener() @commands.Cog.listener()
async def on_relationship_update(self, before: discord.Relationship, after: discord.Relationship): async def on_relationship_update(self, before: discord.Relationship, after: discord.Relationship):
self._logger.debug(__name__, f'Received on_relationship_update:\n\t{before}\n\t{after}') self._logger.trace(__name__, f'Received on_relationship_update:\n\t{before}\n\t{after}')
await self._handle_event(OnRelationshipUpdateABC, before, after) await self._handle_event(OnRelationshipUpdateABC, before, after)