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

Full flush and wait support #20

Open
ashat1701 opened this issue Feb 6, 2023 · 3 comments
Open

Full flush and wait support #20

ashat1701 opened this issue Feb 6, 2023 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@ashat1701
Copy link

ashat1701 commented Feb 6, 2023

Hi, I am very happy to use this crate but there are some problems with flush. Since logging is happened in another thread we can lose some data when main thread terminated (if there are data in channel or non flushed data in appenders). In my opinion log::logger.flush() should wait until channel is empty and every appender flush data.

@zhuxiujia
Copy link
Member

log::logger.flush() It already notifies each worker thread to save the log

@zhuxiujia zhuxiujia added the help wanted Extra attention is needed label Feb 17, 2023
@ashat1701
Copy link
Author

Sorry for misunderstanding. If there are some messages in channel and we stop main thread all that messages wipe out. So we need mechanism to wait until all messages sent to workers.

@zhuxiujia
Copy link
Member

Sorry for misunderstanding. If there are some messages in channel and we stop main thread all that messages wipe out. So we need mechanism to wait until all messages sent to workers.

After log::logger().flush() is executed, it is actually a channel push WaitGroup message wrapped inside fast_log, and then crossbeam::WaitGroup waits for all waitgroups to be processed drop. So log::logger().flush() can be called on the main thread and wait until all messages are consumed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants