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

detect remote loggers in the UI #181399

Merged
merged 1 commit into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/vs/code/node/sharedProcess/sharedProcessMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ class SharedProcessMain extends Disposable {
shortGraceTime: LocalReconnectConstants.ShortGraceTime,
scrollback: configurationService.getValue<number>(TerminalSettingId.PersistentSessionScrollback) ?? 100
},
false,
configurationService,
environmentService,
logService,
Expand Down
1 change: 0 additions & 1 deletion src/vs/platform/environment/common/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ export interface INativeEnvironmentService extends IEnvironmentService {
disableKeytar?: boolean;

crossOriginIsolated?: boolean;
isRemoteServer?: boolean;

// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/request/browser/requestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class RequestService extends AbstractRequestService implements IRequestSe
@IConfigurationService private readonly configurationService: IConfigurationService,
@ILoggerService loggerService: ILoggerService
) {
super(false, loggerService);
super(loggerService);
}

async request(options: IRequestOptions, token: CancellationToken): Promise<IRequestContext> {
Expand Down
5 changes: 2 additions & 3 deletions src/vs/platform/request/common/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ export abstract class AbstractRequestService extends Disposable implements IRequ
private counter = 0;

constructor(
remote: boolean,
loggerService: ILoggerService
) {
super();
this.logger = loggerService.createLogger(remote ? 'remotenetwork' : 'network', {
name: remote ? localize('remote request', "Network Requests (Remote)") : localize('request', "Network Requests"),
this.logger = loggerService.createLogger('network', {
name: localize('request', "Network Requests"),
when: CONTEXT_LOG_LEVEL.isEqualTo(LogLevelToString(LogLevel.Trace)).serialize()
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/request/node/requestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class RequestService extends AbstractRequestService implements IRequestSe
@ILogService private readonly logService: ILogService,
@ILoggerService loggerService: ILoggerService
) {
super(!!environmentService.isRemoteServer, loggerService);
super(loggerService);
this.configure();
this._register(configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('http')) {
Expand Down
4 changes: 1 addition & 3 deletions src/vs/platform/terminal/node/ptyHostMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ const environmentService = new NativeEnvironmentService(parseArgs(process.argv,
// Logging
const loggerService = new LoggerService(LogLevel.Info, environmentService.logsHome);
server.registerChannel(TerminalIpcChannels.Logger, new LoggerChannel(loggerService, () => DefaultURITransformer));
const isRemote = process.env.VSCODE_PTY_REMOTE === 'true';
delete process.env.VSCODE_PTY_REMOTE;
const logger = loggerService.createLogger(isRemote ? 'remoteptyhost' : 'ptyhost', { name: isRemote ? localize('remotePtyHost', "Pty Host (Remote)") : localize('ptyHost', "Pty Host") });
const logger = loggerService.createLogger('ptyhost', { name: localize('ptyHost', "Pty Host") });
const logService = new LogService(logger, [new ConsoleLogger()]);

const heartbeatService = new HeartbeatService();
Expand Down
2 changes: 0 additions & 2 deletions src/vs/platform/terminal/node/ptyHostService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export class PtyHostService extends Disposable implements IPtyService {

constructor(
private readonly _reconnectConstants: IReconnectConstants,
private readonly isRemote: boolean,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@IEnvironmentService private readonly _environmentService: INativeEnvironmentService,
@ILogService private readonly _logService: ILogService,
Expand Down Expand Up @@ -139,7 +138,6 @@ export class PtyHostService extends Disposable implements IPtyService {
args: ['--type=ptyHost', '--logsPath', this._environmentService.logsHome.fsPath],
env: {
VSCODE_LAST_PTY_ID: lastPtyId,
VSCODE_PTY_REMOTE: this.isRemote,
VSCODE_AMD_ENTRYPOINT: 'vs/platform/terminal/node/ptyHostMain',
VSCODE_PIPE_LOGGING: 'true',
VSCODE_VERBOSE_LOGGING: 'true', // transmit console logs from server to client,
Expand Down
1 change: 0 additions & 1 deletion src/vs/server/node/serverEnvironmentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,5 @@ export interface IServerEnvironmentService extends INativeEnvironmentService {
}

export class ServerEnvironmentService extends NativeEnvironmentService implements IServerEnvironmentService {
get isRemoteServer(): boolean { return true; }
override get args(): ServerParsedArgs { return super.args as ServerParsedArgs; }
}
3 changes: 1 addition & 2 deletions src/vs/server/node/serverServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ export async function setupServerServices(connectionToken: ServerConnectionToken
graceTime: ProtocolConstants.ReconnectionGraceTime,
shortGraceTime: ProtocolConstants.ReconnectionShortGraceTime,
scrollback: configurationService.getValue<number>(TerminalSettingId.PersistentSessionScrollback) ?? 100
},
true
}
);
services.set(IPtyService, ptyService);

Expand Down
17 changes: 15 additions & 2 deletions src/vs/workbench/contrib/logs/common/logs.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import { IDefaultLogLevelsService } from 'vs/workbench/contrib/logs/common/defaultLogLevels';
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { CounterSet } from 'vs/base/common/map';
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
import { Schemas } from 'vs/base/common/network';

registerAction2(class extends Action2 {
constructor() {
Expand Down Expand Up @@ -62,6 +64,7 @@ class LogOutputChannels extends Disposable implements IWorkbenchContribution {
@ILoggerService private readonly loggerService: ILoggerService,
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@IFileService private readonly fileService: IFileService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService,
) {
super();
const contextKey = CONTEXT_LOG_LEVEL.bindTo(contextKeyService);
Expand Down Expand Up @@ -138,14 +141,24 @@ class LogOutputChannels extends Disposable implements IWorkbenchContribution {
}

private registerLogChannel(logger: ILoggerResource): void {
if (this.outputChannelRegistry.getChannel(logger.id)) {
const channel = this.outputChannelRegistry.getChannel(logger.id);
if (channel && this.uriIdentityService.extUri.isEqual(channel.file, logger.resource)) {
return;
}
const promise = createCancelablePromise(async token => {
await whenProviderRegistered(logger.resource, this.fileService);
try {
await this.whenFileExists(logger.resource, 1, token);
this.outputChannelRegistry.registerChannel({ id: logger.id, label: logger.name ?? logger.id, file: logger.resource, log: true, extensionId: logger.extensionId });
const channel = this.outputChannelRegistry.getChannel(logger.id);
if (channel?.file?.scheme === Schemas.vscodeRemote) {
// Re-register the channel with new id and name
this.outputChannelRegistry.removeChannel(channel.id);
this.outputChannelRegistry.registerChannel({ id: `${channel.id}.remote`, label: nls.localize('remote name', "{0} (Remote)", channel.label), file: channel.file, log: channel.log, extensionId: channel.extensionId });
}
const hasToAppendRemote = channel && logger.resource.scheme === Schemas.vscodeRemote;
const id = hasToAppendRemote ? `${logger.id}.remote` : logger.id;
const label = hasToAppendRemote ? nls.localize('remote name', "{0} (Remote)", logger.name ?? logger.id) : logger.name ?? logger.id;
this.outputChannelRegistry.registerChannel({ id, label, file: logger.resource, log: true, extensionId: logger.extensionId });
} catch (error) {
if (!isCancellationError(error)) {
this.logService.error('Error while registering log channel', logger.resource.toString(), getErrorMessage(error));
Expand Down