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

Enhance logger service #171174

Merged
merged 1 commit into from Jan 13, 2023
Merged

Enhance logger service #171174

merged 1 commit into from Jan 13, 2023

Conversation

sandy081
Copy link
Member

  • 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
@sandy081 sandy081 enabled auto-merge (squash) January 12, 2023 15:44
@sandy081 sandy081 self-assigned this Jan 12, 2023
@sandy081 sandy081 requested a review from aeschli January 12, 2023 15:44
@VSCodeTriageBot VSCodeTriageBot added this to the January 2023 milestone Jan 12, 2023
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())));

Copy link
Member Author

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") }));
Copy link
Member Author

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") }));
Copy link
Member Author

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.

Copy link
Member Author

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()));
}
}
Copy link
Member Author

@sandy081 sandy081 Jan 12, 2023

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 });
Copy link
Member Author

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.

@sandy081 sandy081 merged commit 222994d into main Jan 13, 2023
@sandy081 sandy081 deleted the sandy081/loggers-output branch January 13, 2023 08:13
@github-actions github-actions bot locked and limited conversation to collaborators Feb 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants