-
Notifications
You must be signed in to change notification settings - Fork 718
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
Send log messages with async function #119
Comments
Hi @wpmjones. 🙂 I don't know very well async programming in Python. While providing a function to Also, I never developed any Discord bot. Is it possible for you to give me a minimal example where I could just replace token / server / channel and start debugging this, please? |
Actually, with the help of a few friends, I got it working.
Essentially, loguru calls the regular function which then uses asyncio to call the async function. It's an extra step, but it works. Now I just have to work on formatting so that it's a gorgeous as it is in the console! :) |
Ok, I'm not so sure on why and how it works, but if you say so, great then. 😁 Also to answer you initial question, I usually call |
--Moved to separate issue-- |
Using Loguru Make sure to await |
I am writing a bot for Discord and using the discord.py library which is async. I want to send some log messages to Discord using the bot.
Essentially, all of the bot activity happens inside a class. I am having a lot of trouble figuring out where to put the logger.add and whether the sink function should be inside the class or outside the class. If it's outside, then the bot can't be accessed from the function (critical to send the message). If it's inside, then I don't know where to put logger.add.
Here is where I am at the moment, but I get errors that
Push.send_log
was never awaited.Any help would be appreciated.
The text was updated successfully, but these errors were encountered: