Skip to content

Commit 42f11aa

Browse files
authored
Merge pull request microsoft#185432 from microsoft/tyriar/terminalLogService
Move all renderer-side terminal logs to ITerminalLogService
2 parents f5fccbd + 94cb59e commit 42f11aa

32 files changed

+116
-83
lines changed

src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class CommandDetectionCapability implements ICommandDetectionCapability {
112112

113113
constructor(
114114
private readonly _terminal: Terminal,
115-
@ILogService private readonly _logService: ILogService
115+
private readonly _logService: ILogService
116116
) {
117117
this._dimensions = {
118118
cols: this._terminal.cols,

src/vs/platform/terminal/common/terminal.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
1515
import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
1616
import { Registry } from 'vs/platform/registry/common/platform';
1717
import type * as performance from 'vs/base/common/performance';
18+
import { ILogService } from 'vs/platform/log/common/log';
1819

1920
export const terminalTabFocusContextKey = new RawContextKey<boolean>('terminalTabFocusMode', false, true);
2021

@@ -1057,3 +1058,13 @@ export const ILocalPtyService = createDecorator<ILocalPtyService>('localPtyServi
10571058
* **This service should only be used within the terminal component.**
10581059
*/
10591060
export interface ILocalPtyService extends IPtyService { }
1061+
1062+
export const ITerminalLogService = createDecorator<ITerminalLogService>('terminalLogService');
1063+
export interface ITerminalLogService extends ILogService {
1064+
/**
1065+
* Similar to _serviceBrand but used to differentiate this service at compile time from
1066+
* ILogService; ITerminalLogService is an ILogService, but ILogService is not an
1067+
* ITerminalLogService.
1068+
*/
1069+
readonly _logBrand: undefined;
1070+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { Disposable } from 'vs/base/common/lifecycle';
7+
import { Event } from 'vs/base/common/event';
8+
import { localize } from 'vs/nls';
9+
import { ILogger, ILoggerService, LogLevel } from 'vs/platform/log/common/log';
10+
import { ITerminalLogService } from 'vs/platform/terminal/common/terminal';
11+
12+
export class TerminalLogService extends Disposable implements ITerminalLogService {
13+
declare _serviceBrand: undefined;
14+
declare _logBrand: undefined;
15+
16+
private readonly _logger: ILogger;
17+
18+
get onDidChangeLogLevel(): Event<LogLevel> { return this._logger.onDidChangeLogLevel; }
19+
20+
constructor(@ILoggerService private readonly _loggerService: ILoggerService) {
21+
super();
22+
this._logger = this._loggerService.createLogger('terminal', { name: localize('terminalLoggerName', 'Terminal') });
23+
}
24+
25+
getLevel(): LogLevel { return this._logger.getLevel(); }
26+
setLevel(level: LogLevel): void { this._logger.setLevel(level); }
27+
trace(message: string, ...args: any[]): void { this._logger.trace(message, args); }
28+
debug(message: string, ...args: any[]): void { this._logger.debug(message, args); }
29+
info(message: string, ...args: any[]): void { this._logger.info(message, args); }
30+
warn(message: string, ...args: any[]): void { this._logger.warn(message, args); }
31+
error(message: string | Error, ...args: any[]): void { this._logger.error(message, args); }
32+
flush(): void { this._logger.flush(); }
33+
}

src/vs/platform/terminal/common/xterm/shellIntegrationAddon.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
209209
private _nonce: string,
210210
private readonly _disableTelemetry: boolean | undefined,
211211
private readonly _telemetryService: ITelemetryService | undefined,
212-
@ILogService private readonly _logService: ILogService
212+
private readonly _logService: ILogService
213213
) {
214214
super();
215215
this._register(toDisposable(() => {

src/vs/server/node/remoteTerminalChannel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { URI } from 'vs/base/common/uri';
1313
import { IURITransformer } from 'vs/base/common/uriIpc';
1414
import { IServerChannel } from 'vs/base/parts/ipc/common/ipc';
1515
import { createRandomIPCHandle } from 'vs/base/parts/ipc/node/ipc.net';
16-
import { ILogService } from 'vs/platform/log/common/log';
1716
import { RemoteAgentConnectionContext } from 'vs/platform/remote/common/remoteAgentEnvironment';
1817
import { IPtyService, IShellLaunchConfig, ITerminalProfile } from 'vs/platform/terminal/common/terminal';
1918
import { IGetTerminalLayoutInfoArgs, ISetTerminalLayoutInfoArgs } from 'vs/platform/terminal/common/terminalProcess';
@@ -32,6 +31,7 @@ import { IProductService } from 'vs/platform/product/common/productService';
3231
import { IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
3332
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
3433
import { withNullAsUndefined } from 'vs/base/common/types';
34+
import { ILogService } from 'vs/platform/log/common/log';
3535

3636
class CustomVariableResolver extends AbstractVariableResolverService {
3737
constructor(

src/vs/workbench/contrib/terminal/browser/baseTerminalBackend.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import { Disposable } from 'vs/base/common/lifecycle';
88
import { Schemas } from 'vs/base/common/network';
99
import { withNullAsUndefined } from 'vs/base/common/types';
1010
import { localize } from 'vs/nls';
11-
import { ILogService } from 'vs/platform/log/common/log';
12-
import { ICrossVersionSerializedTerminalState, IPtyHostController, ISerializedTerminalState } from 'vs/platform/terminal/common/terminal';
11+
import { ICrossVersionSerializedTerminalState, IPtyHostController, ISerializedTerminalState, ITerminalLogService } from 'vs/platform/terminal/common/terminal';
1312
import { themeColorFromId } from 'vs/platform/theme/common/themeService';
1413
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
1514
import { STATUS_BAR_WARNING_ITEM_BACKGROUND, STATUS_BAR_WARNING_ITEM_FOREGROUND } from 'vs/workbench/common/theme';
@@ -32,7 +31,7 @@ export abstract class BaseTerminalBackend extends Disposable {
3231

3332
constructor(
3433
private readonly _ptyHostController: IPtyHostController,
35-
protected readonly _logService: ILogService,
34+
protected readonly _logService: ITerminalLogService,
3635
historyService: IHistoryService,
3736
configurationResolverService: IConfigurationResolverService,
3837
statusBarService: IStatusbarService,

src/vs/workbench/contrib/terminal/browser/remotePty.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import { Barrier } from 'vs/base/common/async';
77
import { Emitter } from 'vs/base/common/event';
88
import { Disposable } from 'vs/base/common/lifecycle';
99
import { URI } from 'vs/base/common/uri';
10-
import { ILogService } from 'vs/platform/log/common/log';
1110
import { IPtyHostProcessReplayEvent, ISerializedCommandDetectionCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
12-
import { IProcessDataEvent, ITerminalChildProcess, ITerminalLaunchError, IProcessProperty, IProcessPropertyMap, ProcessPropertyType, IProcessReadyEvent } from 'vs/platform/terminal/common/terminal';
11+
import { IProcessDataEvent, ITerminalChildProcess, ITerminalLaunchError, IProcessProperty, IProcessPropertyMap, ProcessPropertyType, IProcessReadyEvent, ITerminalLogService } from 'vs/platform/terminal/common/terminal';
1312
import { RemoteTerminalChannelClient } from 'vs/workbench/contrib/terminal/common/remoteTerminalChannel';
1413
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
1514

@@ -47,7 +46,7 @@ export class RemotePty extends Disposable implements ITerminalChildProcess {
4746
readonly shouldPersist: boolean,
4847
private readonly _remoteTerminalChannel: RemoteTerminalChannelClient,
4948
@IRemoteAgentService private readonly _remoteAgentService: IRemoteAgentService,
50-
@ILogService private readonly _logService: ILogService
49+
@ITerminalLogService private readonly _logService: ITerminalLogService
5150
) {
5251
super();
5352
this._startBarrier = new Barrier();

src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ import { IProcessEnvironment, OperatingSystem } from 'vs/base/common/platform';
1111
import { ICommandService } from 'vs/platform/commands/common/commands';
1212
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1313
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
14-
import { ILogService } from 'vs/platform/log/common/log';
1514
import { Registry } from 'vs/platform/registry/common/platform';
1615
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
1716
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
1817
import { ISerializedTerminalCommand } from 'vs/platform/terminal/common/capabilities/capabilities';
19-
import { IShellLaunchConfig, IShellLaunchConfigDto, ITerminalBackend, ITerminalBackendRegistry, ITerminalChildProcess, ITerminalEnvironment, ITerminalProcessOptions, ITerminalProfile, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, ProcessPropertyType, TerminalExtensions, TerminalIcon, TerminalSettingId, TitleEventSource } from 'vs/platform/terminal/common/terminal';
18+
import { IShellLaunchConfig, IShellLaunchConfigDto, ITerminalBackend, ITerminalBackendRegistry, ITerminalChildProcess, ITerminalEnvironment, ITerminalLogService, ITerminalProcessOptions, ITerminalProfile, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, ProcessPropertyType, TerminalExtensions, TerminalIcon, TerminalSettingId, TitleEventSource } from 'vs/platform/terminal/common/terminal';
2019
import { IProcessDetails } from 'vs/platform/terminal/common/terminalProcess';
2120
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
2221
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
@@ -64,7 +63,7 @@ class RemoteTerminalBackend extends BaseTerminalBackend implements ITerminalBack
6463
private readonly _remoteTerminalChannel: RemoteTerminalChannelClient,
6564
@IRemoteAgentService private readonly _remoteAgentService: IRemoteAgentService,
6665
@IInstantiationService private readonly _instantiationService: IInstantiationService,
67-
@ILogService logService: ILogService,
66+
@ITerminalLogService logService: ITerminalLogService,
6867
@ICommandService private readonly _commandService: ICommandService,
6968
@IStorageService private readonly _storageService: IStorageService,
7069
@IRemoteAuthorityResolverService private readonly _remoteAuthorityResolverService: IRemoteAuthorityResolverService,

src/vs/workbench/contrib/terminal/browser/terminal.contribution.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { TerminalQuickAccessProvider } from 'vs/workbench/contrib/terminal/brows
3232
import { registerTerminalConfiguration } from 'vs/workbench/contrib/terminal/common/terminalConfiguration';
3333
import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from 'vs/platform/accessibility/common/accessibility';
3434
import { terminalViewIcon } from 'vs/workbench/contrib/terminal/browser/terminalIcons';
35-
import { TerminalSettingId, WindowsShellType } from 'vs/platform/terminal/common/terminal';
35+
import { ITerminalLogService, TerminalSettingId, WindowsShellType } from 'vs/platform/terminal/common/terminal';
3636
import { isIOS, isWindows } from 'vs/base/common/platform';
3737
import { setupTerminalMenus } from 'vs/workbench/contrib/terminal/browser/terminalMenus';
3838
import { TerminalInstanceService } from 'vs/workbench/contrib/terminal/browser/terminalInstanceService';
@@ -52,8 +52,10 @@ import { RemoteTerminalBackendContribution } from 'vs/workbench/contrib/terminal
5252
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
5353
import { TerminalMainContribution } from 'vs/workbench/contrib/terminal/browser/terminalMainContribution';
5454
import { Schemas } from 'vs/base/common/network';
55+
import { TerminalLogService } from 'vs/platform/terminal/common/terminalLogService';
5556

5657
// Register services
58+
registerSingleton(ITerminalLogService, TerminalLogService, InstantiationType.Delayed);
5759
registerSingleton(ITerminalService, TerminalService, InstantiationType.Delayed);
5860
registerSingleton(ITerminalEditorService, TerminalEditorService, InstantiationType.Delayed);
5961
registerSingleton(ITerminalGroupService, TerminalGroupService, InstantiationType.Delayed);

src/vs/workbench/contrib/terminal/browser/terminalInstance.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
3939
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
4040
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
4141
import { ResultKind } from 'vs/platform/keybinding/common/keybindingResolver';
42-
import { ILogService } from 'vs/platform/log/common/log';
4342
import { INotificationService, IPromptChoice, Severity } from 'vs/platform/notification/common/notification';
4443
import { IOpenerService } from 'vs/platform/opener/common/opener';
4544
import { IProductService } from 'vs/platform/product/common/productService';
@@ -50,7 +49,7 @@ import { IMarkProperties, ITerminalCommand, TerminalCapability } from 'vs/platfo
5049
import { TerminalCapabilityStoreMultiplexer } from 'vs/platform/terminal/common/capabilities/terminalCapabilityStore';
5150
import { IEnvironmentVariableCollection, IMergedEnvironmentVariableCollection } from 'vs/platform/terminal/common/environmentVariable';
5251
import { deserializeEnvironmentVariableCollections } from 'vs/platform/terminal/common/environmentVariableShared';
53-
import { IProcessDataEvent, IProcessPropertyMap, IReconnectionProperties, IShellLaunchConfig, ITerminalDimensionsOverride, ITerminalLaunchError, PosixShellType, ProcessPropertyType, ShellIntegrationStatus, TerminalExitReason, TerminalIcon, TerminalLocation, TerminalSettingId, TerminalShellType, TitleEventSource, WindowsShellType } from 'vs/platform/terminal/common/terminal';
52+
import { IProcessDataEvent, IProcessPropertyMap, IReconnectionProperties, IShellLaunchConfig, ITerminalDimensionsOverride, ITerminalLaunchError, ITerminalLogService, PosixShellType, ProcessPropertyType, ShellIntegrationStatus, TerminalExitReason, TerminalIcon, TerminalLocation, TerminalSettingId, TerminalShellType, TitleEventSource, WindowsShellType } from 'vs/platform/terminal/common/terminal';
5453
import { formatMessageForTerminal } from 'vs/platform/terminal/common/terminalStrings';
5554
import { editorBackground } from 'vs/platform/theme/common/colorRegistry';
5655
import { getIconRegistry } from 'vs/platform/theme/common/iconRegistry';
@@ -337,7 +336,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
337336
@IClipboardService private readonly _clipboardService: IClipboardService,
338337
@IThemeService private readonly _themeService: IThemeService,
339338
@IConfigurationService private readonly _configurationService: IConfigurationService,
340-
@ILogService private readonly _logService: ILogService,
339+
@ITerminalLogService private readonly _logService: ITerminalLogService,
341340
@IDialogService private readonly _dialogService: IDialogService,
342341
@IStorageService private readonly _storageService: IStorageService,
343342
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService,

0 commit comments

Comments
 (0)