Created
December 28, 2019 21:38
-
-
Save ioquatix/6eafd57374ef73d299fdfddfab2f4979 to your computer and use it in GitHub Desktop.
Async nested logging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env RBENV_VERSION=2.7.0 ruby | |
gem 'async' | |
require 'async' | |
Async do |task| | |
Async.logger.info("Incoming request...") | |
Async(logger: task.logger.with(name: "request-id-1234")) do | |
Async.logger.info("Database Query") | |
Async do | |
Async.logger.info("HTTP request") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use serialized output too:
(There was a bug in console 1.6.0 so preparing 1.7.0 which makes the above possible).