microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.45k stars 28.62k forks source link

Ability to set log levels by output channel #223536

Open rudyflores opened 1 month ago

rudyflores commented 1 month ago

I been working on an extensions that utilizes the OutputChannel API for logging things into the output view for different log levels such as: INFO, ERROR, etc...

Each of these loggers output independent information from each other, let's call this logger A and logger B. My feature request is the possibility to allow setting an individual log level at a per logger basis, so for example logger A could have a DEBUG level and logger B could have a TRACE level logging occur. This could be further enanced by using the set log level (as it works today) if the log level is not specified for that specific logger upon creation.

This is what I envision this API to look like:

// Case where log level is defined
const outputChannel = vscode.window.createOutputChannel('loggerA', { log: true }, 'DEBUG');

// Case where log level is not defined (will use default log level)
const outputChannel = vscode.window.createOutputChannel('loggerB', { log: true });

And even perhaps add a way to update this later with something like:

outputChannel.setLogLevel('TRACE');

For setting these log level a user can perhaps even use this enumerator from VS Code's docs: https://code.visualstudio.com/api/references/vscode-api#LogLevel

VSCodeTriageBot commented 1 month ago

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!

rudyflores commented 3 weeks ago

Adding some additional context here, I noticed the UI allows setting independent log levels through Developer: Set Log Level..., but is also the only way to achieve this. I would love for VS Code to add to it's API for OutputChannel to set this independent log level similar to how this UI allows it!

vs-code-engineering[bot] commented 3 weeks ago

:slightly_smiling_face: This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!