Do not show complete content after reload if output is cleared
Type: Bug
I'm building an extension that uses the LogOutputChannel to output some logs when the extension activates.
I started noticing that everytime I reloaded the window, I'd end up with the same logs twice: the logs from the previous activation, and the logs from the current activation.
I assumed that the channel wasn't cleared automatically so at first I manually cleared the output channel using the context menu action before reloading the window. Unfortunately, this still results in the logs from the previous activation being shown. Programmatically clearing the output channel using the clear method did not work either.
The only way I could the channel to clear was to completely restart VS Code.
I'm thinking maybe the buffer is not being cleared and when the window is reloaded, the logs from the current activation are appended to the logs from the previous one.
VS Code version: Code 1.86.1 (31c37ee8f63491495ac49e43b8544550fbae4533, 2024-02-07T09:09:01.236Z) OS version: Darwin x64 23.2.0 Modes:
System Info
| Item | Value |
|---|---|
| CPUs | Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 2400) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: disabled_off direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_graphite: disabled_off video_decode: enabled video_encode: enabled webgl: enabled webgl2: enabled webgpu: enabled |
| Load (avg) | 2, 3, 3 |
| Memory (System) | 32.00GB (7.05GB free) |
| Process Argv | |
| Screen Reader | no |
| VM | 0% |
https://github.com/microsoft/vscode/assets/649677/d5fceb10-1003-4438-ae99-90665809634e
It is designed that logs are retained on window reload
I understand persisting the logs between window reloads, but why persist them after having explicitly cleared them? This certainly feels counterintuitive.
but why persist them after having explicitly cleared them
Good point.
Should this be reopened?
As discussed in #232500, the behavior with regards to the log file written to disk is also different on WSL compared to MacOS:
- Inside an extension, create a
LogOutputChannelvia:
const logger = vscode.window.createOutputChannel("My extension", { log: true });
- Use
Developer: Open Log Fileto open the log file forMy extension. - On Linux (WSL2 Ubuntu), we observe that after a
Developer: Reload Window, when usingOpen Log Fileagain, a new log file is opened that VSCode neatly created for us in the folderexthost<some_number+1>. Here,<some_numberis the number for the folder in which the log file resided prior to the window reload. - However, on MacOS (
Darwin 23.6.0 arm64), we notice that the same logfile is reused and lines are only appended to it. Is there a way we can force a new log file to be created on this system as well? Or at least that the old logfile is cleared?logger.clear()orlogger.dispose()does not seem to work, it only clears the log from the output pane but does not affect the log file.
Could you reopen this issue @sandy081 ? You've acknowledged the problem, but it seems you forgot to reopen the issue. I'm afraid this won't ever get solved if it stays closed.
This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.
Happy Coding!
This is not a feature request, but a bug report.
Thanks for reopening @sandy081! I think the feature request tag should also be removed too, if you don't mind.
I am sorry, this is not a bug, this is existing intended behaviour. To support this, we should support both behaviour. Hence tagged as feature request.
Thanks
I respectfully disagree. Explicitly clearing the logs does not actually clear them, which feels like a bug, wouldn't you agree?
Agreed. I missed clearing the log action in the issue. Thanks for reminding that.