Wrap stderr in a structure log delegator #564
Merged
+43
−20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After #559, the server and its add-ons can send notifications, but regular
puts
that would normally be redirected to stderr are now lost.Trying to account for any type of print in the notifier thread would be difficult. We need to be able to match against the
\r\n\r\n
separator, so that we can know exactly the start and end of a structured message.So I propose we wrap stderr in a delegator instead. Essentially, any method invoked on
stderr
will still be redirect to it, but it gives us an opportunity to overrideputs
andprint
to use structured logging, instead of just writing the strings directly to the pipe.I tested this with the Tapioca add-on and I'm able to accurately see both progress notifications and messages in the output tab.