Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test extension logging API #164434

Closed
3 tasks done
sandy081 opened this issue Oct 24, 2022 · 2 comments
Closed
3 tasks done

Test extension logging API #164434

sandy081 opened this issue Oct 24, 2022 · 2 comments

Comments

@sandy081
Copy link
Member

sandy081 commented Oct 24, 2022

Refs: #159892, #161944

Complexity: 5

Create Issue


Proposal

Added, logLevel and the corresponding change event to the output channel and env. Please test these APIs.

export namespace env {
/**
* The current log level of the application.
*/
export const logLevel: LogLevel;
/**
* An {@link Event} which fires when the log level of the application changes.
*/
export const onDidChangeLogLevel: Event<LogLevel>;
}

/**
* A channel for containing log output.
*/
export interface LogOutputChannel extends OutputChannel {
/**
* The current log level of the channel.
*/
readonly logLevel: LogLevel;
/**
* An {@link Event} which fires when the log level of the channel changes.
*/
readonly onDidChangeLogLevel: Event<LogLevel>;

Testing

Create a log output channel using the following API

export function createOutputChannel(name: string, options: { readonly log: true }): LogOutputChannel;

Env: Testing Log Level and the change event for all logs

Configure log levels for all log channels using the command Set Log Level... and make sure

  • log level change is being propagated in env and also in your log output channel
  • log output channel UI is not logging the logs those do not respect the set log level.

Log Output Channel: Testing Log Level and the change event for a log output channel

Configure log levels for this log channel using the command Set Log Level... and make sure

  • log level is being propagated to your output channel
  • log output channel UI is not logging the logs those do not respect the set log level.
  • this overrides the log level configured for all loggers.

CLI: Testing Log Level configure from CLI

You can now configure the default log level for an extension from CLI using the format code --log <extensionId>:<logLevel>, for eg., the following sets the log level to trace for all log output channels of vscode.git extension.

code --log vscode.git:trace

Following will set the log level to debug for all loggers (Note this format is already supported)

code --log debug

Please make sure

  • the configured log level is propagated to your output channel
  • the log level that was set for all loggers from the command line, is propagated to your output channel and also in env
  • log output channel UI is not logging the logs those do not respect the configured log level.
  • the documentation in the CLI explains this.
@karthiknadig
Copy link
Member

karthiknadig commented Oct 25, 2022

@sandy081 This command did not work for me code-insiders --log vscode.git:trace . but code-insiders . works. I verified that vscode.git is installed. Created #164661 to track this.

@karthiknadig
Copy link
Member

Tries this with a language server client. works fantastically!!!
image

These are being logged from python over LSP through language client.

@karthiknadig karthiknadig removed their assignment Oct 25, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants