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

Async Handlers #98

Open
rofinn opened this issue Aug 9, 2018 · 3 comments
Open

Async Handlers #98

rofinn opened this issue Aug 9, 2018 · 3 comments

Comments

@rofinn
Copy link
Member

rofinn commented Aug 9, 2018

Rather having loggers asynchronously calling handlers, we should allow handlers to take an async argument during construction which allows it to control how messages are asynchronously emitted.

@nicoleepp
Copy link
Contributor

Some useful notes:

@nicoleepp
Copy link
Contributor

If #96 (comment) is true, in particular

We'll still need to be careful in the emit methods that @async is being called after we've formatted the record.

Then I'm not sure it makes sense to have an async option at all, as in most emit functions the only thing that occurs after the formatting is actually calling printstyled or println.

A way this might work is to asynchronously format the record for all its loggers, then asynchronously send the formatted string to their emit message, which will mean

emit(handler::DefaultHandler{F, O}, rec::Record) -> emit(handler::DefaultHandler{F, O}, rec::Record, formatted_str)

Which I'm not sure we want to do?

@rofinn
Copy link
Member Author

rofinn commented Mar 29, 2019

Then I'm not sure it makes sense to have an async option at all, as in most emit functions the only thing that occurs after the formatting is actually calling printstyled or println

That's exactly where we'd want to use @async because println or generally writing the message may be high latency with low cpu usage. Formatting the message should be relatively CPU intensive, so @async won't get us much there. I suppose one thing we should do is run the println, write, etc in a try/catch to warn about any failure in the task.

@nicoleepp nicoleepp self-assigned this Apr 2, 2019
@nicoleepp nicoleepp removed their assignment Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants