Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable discord.py logger by default. #3216

Merged
merged 8 commits into from
Jul 15, 2023

Conversation

Jerrie-Aries
Copy link
Contributor

@Jerrie-Aries Jerrie-Aries commented Oct 9, 2022

Refer to #3213.

  • This will log discord.py library logs to sys.stdout by default.
  • Defaults to INFO level.
  • If the LOG_DISCORD DISCORD_LOG_LEVEL env config variable is set to DEBUG, the DEBUG level logs will be logged into a file i.e. discord.log separately while still logging the INFO level to sys.stdout.
  • Reorder imports and move logger stuff to top to properly initialize colorama and set text color to loggers. Otherwise the discord.py logger text would be in white. This is kinda un-pythonic (type-checker will not like this). Proper way would be creating a new file for logger classes and stuff, and do early import of that file in bot.py to initialize those. I saw the implementation in Red-DiscordBot if I remember correctly. Let me know if this should be reverted.

@Jerrie-Aries Jerrie-Aries marked this pull request as ready for review October 15, 2022 01:27
bot.py Outdated Show resolved Hide resolved
bot.py Outdated Show resolved Hide resolved
bot.py Outdated Show resolved Hide resolved
core/models.py Outdated Show resolved Hide resolved
bot.py Outdated Show resolved Hide resolved
bot.py Show resolved Hide resolved
@Jerrie-Aries Jerrie-Aries requested a review from Taaku18 March 22, 2023 04:44
- Restore import orders
- Logging stuff is now completely handled in `core.models.configure_logging`
@Jerrie-Aries Jerrie-Aries linked an issue Mar 25, 2023 that may be closed by this pull request
2 tasks
Taaku18
Taaku18 previously approved these changes Jul 13, 2023
Copy link
Collaborator

@Taaku18 Taaku18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I made a few changes, notably:

  • discord.py logs won't be logged into a separate log file, but instead the same file as the bot.
  • Changed maxBytes from 48000 (48kb) to 28000000 (28mb), the previous value was only enough for 6000 characters.
  • Some stylistic changes, and updated changelog.

Would be great if you can double-check my edit, and then this PR's good to go!

@Jerrie-Aries
Copy link
Contributor Author

Jerrie-Aries commented Jul 13, 2023

Looks good to me.

But I just got this error when scrolling through the pages from ?debug command.
DISCORD_LOG_LEVEL was set to Debug.

2023-07-13 16:16:33 discord.ui.view[412] - ERROR: Ignoring exception in view <PaginatorView timeout=210 children=5> for item <PageButton style=<ButtonStyle.primary: 1> url=None disabled=False label='>' emoji=None row=None>
Traceback (most recent call last):
  File "/User/Projects/modmail/.venv/lib/python3.9/site-packages/discord/ui/view.py", line 425, in _scheduled_task
    await item.callback(interaction)
  File "/User/Projects/modmail/core/paginator.py", line 285, in callback
    await interaction.response.edit_message(**kwargs, view=self.view)
  File "/User/Projects/modmail/.venv/lib/python3.9/site-packages/discord/interactions.py", line 812, in edit_message
    await adapter.create_interaction_response(
  File "/User/Projects/modmail/.venv/lib/python3.9/site-packages/discord/webhook/async_.py", line 221, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.content: Must be 2000 or fewer in length.

Maybe some of the lines just have more than 2000 characters in it (single line)?

Update:
I've found the issue, it's in async def debug in cogs/utility.py. I'll just push the commit to this branch.

Taaku18
Taaku18 previously approved these changes Jul 13, 2023
Copy link
Collaborator

@Taaku18 Taaku18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good to me!

@Taaku18 Taaku18 added staged Staged for next version and removed in progress labels Jul 13, 2023
@Taaku18 Taaku18 merged commit 43fbc31 into modmail-dev:development Jul 15, 2023
@Taaku18 Taaku18 mentioned this pull request Jul 15, 2023
@Jerrie-Aries Jerrie-Aries deleted the discord-logger branch July 15, 2023 13:57
raidensakura pushed a commit to raidensakura/modmail that referenced this pull request Apr 10, 2024
* Enable `discord.py` logger by default.

* Revert:

- Restore import orders
- Logging stuff is now completely handled in `core.models.configure_logging`

* Update logging configurations

* Updated changelog

* Fix overflow characters in logs when using `?debug` command.

* Update changelog

---------

Co-authored-by: Taku <45324516+Taaku18@users.noreply.github.com>
khakers pushed a commit to khakers/OpenModmail that referenced this pull request Jun 18, 2024
* Enable `discord.py` logger by default.

* Revert:

- Restore import orders
- Logging stuff is now completely handled in `core.models.configure_logging`

* Update logging configurations

* Updated changelog

* Fix overflow characters in logs when using `?debug` command.

* Update changelog

---------

Co-authored-by: Taku <45324516+Taaku18@users.noreply.github.com>

(cherry picked from commit 43fbc31)
Signed-off-by: Khakers <22665282+khakers@users.noreply.github.com>
khakers pushed a commit to khakers/OpenModmail that referenced this pull request Jun 18, 2024
* Enable `discord.py` logger by default.

* Revert:

- Restore import orders
- Logging stuff is now completely handled in `core.models.configure_logging`

* Update logging configurations

* Updated changelog

* Fix overflow characters in logs when using `?debug` command.

* Update changelog

---------

Co-authored-by: Taku <45324516+Taaku18@users.noreply.github.com>

(cherry picked from commit 43fbc31)
Signed-off-by: Khakers <22665282+khakers@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
staged Staged for next version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Log the discord logger to console.
2 participants