abrahammurciano / discord-lumberjack

A Python logging handler which sends its logs to a Discord Channel
GNU General Public License v3.0
4 stars 1 forks source link

Program exits and last logs are not sent to Discord #35

Closed aidanmelen closed 2 years ago

aidanmelen commented 2 years ago

I have noticed some interesting behavior. if the program exits normally then the last last few log events are not sent to Discord. However, you if place a time.sleep(10) at the end, there is a better chance the logs are flushed and sent to Discord.

aidanmelen commented 2 years ago

perhaps _assert_messages_sent shouldn't only exist for testing purposes

abrahammurciano commented 2 years ago

That's a great observation! Thanks for your valuable input. Let me think about it, and I'll update you here soon

abrahammurciano commented 2 years ago

See this:

https://stackoverflow.com/questions/70733909/can-i-run-cleanup-code-in-daemon-threads-in-python

In the meantime, since I suspect there is no good solution to my question, I guess I'll have to expose a way for you (the user) to wait for messages to send before exiting.

abrahammurciano commented 2 years ago

btw, feel free to join my discord server. you can ask questions/make suggestions about this project over there https://discord.com/invite/mzhSRnnY78

abrahammurciano commented 2 years ago

There was a quite elegant solution posted to the SO link above, I'll be implementing it for v1.0.5 soon, and thus will be deprecating the flush method.