Skip to content

Commit a3c7981

Browse files
committed
Fix logging not showing up on first window
1 parent 57d5861 commit a3c7981

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

src/vs/code/electron-main/app.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import { IssueMainService } from 'vs/platform/issue/electron-main/issueMainServi
6060
import { IKeyboardLayoutMainService, KeyboardLayoutMainService } from 'vs/platform/keyboardLayout/electron-main/keyboardLayoutMainService';
6161
import { ILaunchMainService, LaunchMainService } from 'vs/platform/launch/electron-main/launchMainService';
6262
import { ILifecycleMainService, LifecycleMainPhase, ShutdownReason } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
63-
import { ILogService } from 'vs/platform/log/common/log';
63+
import { ILoggerService, ILogService } from 'vs/platform/log/common/log';
6464
import { IMenubarMainService, MenubarMainService } from 'vs/platform/menubar/electron-main/menubarMainService';
6565
import { INativeHostMainService, NativeHostMainService } from 'vs/platform/native/electron-main/nativeHostMainService';
6666
import { IProductService } from 'vs/platform/product/common/productService';
@@ -136,6 +136,7 @@ export class CodeApplication extends Disposable {
136136
private readonly userEnv: IProcessEnvironment,
137137
@IInstantiationService private readonly mainInstantiationService: IInstantiationService,
138138
@ILogService private readonly logService: ILogService,
139+
@ILoggerService private readonly loggerService: ILoggerService,
139140
@IEnvironmentMainService private readonly environmentMainService: IEnvironmentMainService,
140141
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
141142
@IConfigurationService private readonly configurationService: IConfigurationService,
@@ -934,8 +935,9 @@ export class CodeApplication extends Disposable {
934935
const ptyHostService = new PtyHostService(
935936
ptyHostStarter,
936937
this.configurationService,
938+
this.lifecycleMainService,
937939
this.logService,
938-
// accessor.get(ILoggerMainService)
940+
this.loggerService
939941
);
940942
ptyHostService.initialize();
941943
services.set(ILocalPtyService, ptyHostService);

src/vs/platform/terminal/node/ptyHostMain.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Server as UtilityProcessServer } from 'vs/base/parts/ipc/node/ipc.mp';
1010
import { localize } from 'vs/nls';
1111
import { OPTIONS, parseArgs } from 'vs/platform/environment/node/argv';
1212
import { NativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
13-
import { ConsoleLogger, LogLevel } from 'vs/platform/log/common/log';
13+
import { ConsoleLogger, getLogLevel } from 'vs/platform/log/common/log';
1414
import { LoggerChannel } from 'vs/platform/log/common/logIpc';
1515
import { LogService } from 'vs/platform/log/common/logService';
1616
import { LoggerService } from 'vs/platform/log/node/loggerService';
@@ -35,7 +35,7 @@ const productService: IProductService = { _serviceBrand: undefined, ...product }
3535
const environmentService = new NativeEnvironmentService(parseArgs(process.argv, OPTIONS), productService);
3636

3737
// Logging
38-
const loggerService = new LoggerService(LogLevel.Info, environmentService.logsHome);
38+
const loggerService = new LoggerService(getLogLevel(environmentService), environmentService.logsHome);
3939
server.registerChannel(TerminalIpcChannels.Logger, new LoggerChannel(loggerService, () => DefaultURITransformer));
4040
const logger = loggerService.createLogger('ptyhost', { name: localize('ptyHost', "Pty Host") });
4141
const logService = new LogService(logger, [new ConsoleLogger()]);

src/vs/platform/terminal/node/ptyHostService.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { Emitter } from 'vs/base/common/event';
6+
import { Emitter, Event } from 'vs/base/common/event';
77
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
88
import { IProcessEnvironment, OperatingSystem, isWindows } from 'vs/base/common/platform';
99
import { ProxyChannel } from 'vs/base/parts/ipc/common/ipc';
1010
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
11-
import { ILogService } from 'vs/platform/log/common/log';
11+
import { ILogService, ILoggerService } from 'vs/platform/log/common/log';
12+
import { RemoteLoggerChannelClient } from 'vs/platform/log/common/logIpc';
1213
import { getResolvedShellEnv } from 'vs/platform/shell/node/shellEnv';
1314
import { IPtyHostProcessReplayEvent } from 'vs/platform/terminal/common/capabilities/capabilities';
1415
import { RequestStore } from 'vs/platform/terminal/common/requestStore';
@@ -77,7 +78,7 @@ export class PtyHostService extends Disposable implements IPtyService {
7778
private readonly _ptyHostStarter: IPtyHostStarter,
7879
@IConfigurationService private readonly _configurationService: IConfigurationService,
7980
@ILogService private readonly _logService: ILogService,
80-
// @ILoggerService private readonly _loggerService: ILoggerService,
81+
@ILoggerService private readonly _loggerService: ILoggerService,
8182
) {
8283
super();
8384

@@ -152,9 +153,6 @@ export class PtyHostService extends Disposable implements IPtyService {
152153
}
153154
}));
154155

155-
// TODO: Setup logging
156-
// this._register(new RemoteLoggerChannelClient(this._loggerService, client.getChannel(TerminalIpcChannels.Logger)));
157-
158156
// Create proxy and forward events
159157
const proxy = ProxyChannel.toService<IPtyService>(client.getChannel(TerminalIpcChannels.PtyHost));
160158
this._register(proxy.onProcessData(e => this._onProcessData.fire(e)));
@@ -165,6 +163,12 @@ export class PtyHostService extends Disposable implements IPtyService {
165163
this._register(proxy.onProcessOrphanQuestion(e => this._onProcessOrphanQuestion.fire(e)));
166164
this._register(proxy.onDidRequestDetach(e => this._onDidRequestDetach.fire(e)));
167165

166+
// HACK: When RemoteLoggerChannelClient is not delayed, the Pty Host log file won't show up
167+
// in the Output view of the first window?
168+
Event.once(Event.any(proxy.onProcessReady, proxy.onProcessReplay))(() => {
169+
this._register(new RemoteLoggerChannelClient(this._loggerService, client.getChannel(TerminalIpcChannels.Logger)));
170+
});
171+
168172
return [connection, proxy];
169173
}
170174

0 commit comments

Comments
 (0)