Commit 99dace1
authored
Wrap stderr in a structure log delegator (#564)
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 override `puts` and `print` 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.1 parent 92795ff commit 99dace1
File tree
2 files changed
+43
-20
lines changed- lib/ruby_lsp/ruby_lsp_rails
- test/ruby_lsp_rails
2 files changed
+43
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
197 | 198 | | |
198 | 199 | | |
199 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
200 | 218 | | |
201 | 219 | | |
202 | 220 | | |
| |||
218 | 236 | | |
219 | 237 | | |
220 | 238 | | |
221 | | - | |
| 239 | + | |
222 | 240 | | |
223 | 241 | | |
224 | 242 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | 161 | | |
181 | 162 | | |
182 | 163 | | |
| |||
252 | 233 | | |
253 | 234 | | |
254 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
255 | 260 | | |
256 | 261 | | |
257 | 262 | | |
| |||
0 commit comments