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
Enhance logger service #171174
Enhance logger service #171174
Conversation
sandy081
commented
Jan 12, 2023
- ILoggerService centrailised place for all loggers
- Provide options to display logger while creating/registering logger
- Listen to logger service and register log output channels accordingly
- Adopt this at all places where loggers are created
- Provide options to display logger while creating/registering logger - Listen to logger service and register log output channels accordingly - Adopt this at all places where loggers are created
const isVisible = () => supportsTelemetry(productService, environmentService) && logService.getLevel() === LogLevel.Trace; | ||
this.logger = this._register(loggerService.createLogger(telemetryLogResource, { id: telemetryLogChannelId, name: localize('telemetryLog', "Telemetry{0}", logSuffix), hidden: !isVisible() })); | ||
this._register(logService.onDidChangeLogLevel(() => loggerService.setVisibility(telemetryLogResource, isVisible()))); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CC @lramos15 - You do not need to create output channel now. You can include all necessary info while creating the logger and system will create it whenever you want. For eg., here you can change the visibility of the logger and it will allow system to create/remove the channel.
@@ -17,7 +18,7 @@ export class EditSessionsLogService extends AbstractLogger implements IEditSessi | |||
@IEnvironmentService environmentService: IEnvironmentService | |||
) { | |||
super(); | |||
this.logger = this._register(loggerService.createLogger(environmentService.editSessionsLogResource, { name: 'editsessions' })); | |||
this.logger = this._register(loggerService.createLogger(environmentService.editSessionsLogResource, { id: editSessionsLogId, name: localize('cloudChangesLog', "Cloud Changes") })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joyceerhl you do not need to create output channel now. You can include all necessary info while creating the logger and system will create it automatically.
@@ -174,8 +173,7 @@ export class BackLayerWebView<T extends ICommonCellInfo> extends Themable { | |||
super(themeService); | |||
|
|||
const logsPath = joinPath(environmentService.windowLogsPath, 'notebook.rendering.log'); | |||
this._renderLogger = this._register(loggerService.createLogger(logsPath, { name: 'notebook.rendering' })); | |||
registerLogChannel(logChannelId, nls.localize('renderChannelName', "Notebook rendering"), logsPath, fileService, logService); | |||
this._renderLogger = this._register(loggerService.createLogger(logsPath, { id: logChannelId, name: nls.localize('renderChannelName', "Notebook rendering") })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rebornix you do not need to create output channel now. You can include all necessary info while creating the logger and system will create it automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry wrong ping. CC @mjbvz
private _registerLogChannel(id: string, label: string, file: URI): void { | ||
const promise = registerLogChannel(id, label, file, this._fileService, this._logService); | ||
this._register(toDisposable(() => promise.cancel())); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tyriar you do not need to create output channel now. You can include all necessary info while creating or registering the logger and system will create it automatically.
@@ -187,13 +187,13 @@ export class PtyHostService extends Disposable implements IPtyService { | |||
const logChannel = client.getChannel(TerminalIpcChannels.Log); | |||
LogLevelChannelClient.setLevel(logChannel, this._logService.getLevel()); | |||
const ptyHostLogResource = URI.file(join(this._environmentService.logsPath, `${TerminalLogConstants.FileName}.log`)); | |||
this._loggerService.registerLoggerResource({ id: 'ptyHostLog', name: localize('ptyHost', "Pty Host"), resource: ptyHostLogResource }); | |||
this._loggerService.registerLogger({ id: 'ptyHostLog', name: localize('ptyHost', "Pty Host"), resource: ptyHostLogResource }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tyriar In your case you have to register the logger with the main logger service because your logger is created in a different process. Registering shall be sufficient for the system to create output channel for your logger.