-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
Expose log level and log path to extensions #40053
Comments
A similar API was previously prototyped here: https://github.com/Microsoft/vscode/blob/verbose-logging-mode/src/vs/vscode.proposed.d.ts#L251 That version used different model for enabling or disabling logging: starting code with the If we use the |
// cc @joaomoreno @sandy081 @jrieken |
It should be unique to each Shouldn't there be a I also fear that providing a |
Yeah, why don't we expose a logger? Like |
Yes, I like the idea of exposing logger in the API and extensions can use that. (which was also thought about #39365). Under the hood we can have log file per extension. |
In cases like debug adapters or language servers, it would take extra effort to pipe log messages back into the extension host, and would create a ton of unnecessary IPC traffic, so it's better to let them write directly to some file. But I would support having a logger and also exposing their log folder. |
Working on this - export namespace env {
[...]
export let logger: ILogger;
}
export interface ILogger {
onDidChangeLogLevel: Event<LogLevel>;
getLevel(): LogLevel;
getLogDirectory(): Promise<string>;
trace(message: string, ...args: any[]): void;
debug(message: string, ...args: any[]): void;
info(message: string, ...args: any[]): void;
warn(message: string, ...args: any[]): void;
error(message: string | Error, ...args: any[]): void;
critical(message: string | Error, ...args: any[]): void;
} |
Looks good overall. Not sure if |
LogLevel is never synced across processes currently, right? |
@roblourens Log level is synced across processes during start up. But when changed afterwards using the command, then it is applied only to current renderer process. I am planning to sync it across processes. I suppose each extension gets its own instance of logger thereby logging into a separate file (one log file per extension)? |
Yep, that's what my PR does. |
Problem
The TS extension currently provides its own logging logic to write TSServer events to a file on the disk. We would like to allow extensions like TS to make use of the new logging infrastructure that was added VS Code 1.19, so that logs from both core and extensions can be written to a common logging directory
Proposed API
Add two new properties on
ExtensionContext
:The loggingDirectory would be unique to each extension and created when the extension first accesses the property. This prevents two extensions from overwriting each other if both use a file called
log
for exampleThe text was updated successfully, but these errors were encountered: