Merge pull request #97066 from microsoft/sandy081/delaySpdlog
create spdlog service after workbench is restored
This commit is contained in:
commit
052fca0b45
|
@ -20,9 +20,8 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle
|
|||
import { KeyboardMapperFactory } from 'vs/workbench/services/keybinding/electron-browser/nativeKeymapService';
|
||||
import { INativeWindowConfiguration } from 'vs/platform/windows/node/window';
|
||||
import { ISingleFolderWorkspaceIdentifier, IWorkspaceInitializationPayload, ISingleFolderWorkspaceInitializationPayload, reviveWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { ConsoleLogService, MultiplexLogService, ILogService, ConsoleLogInMainService } from 'vs/platform/log/common/log';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { NativeStorageService } from 'vs/platform/storage/node/storageService';
|
||||
import { LoggerChannelClient, FollowerLogService } from 'vs/platform/log/common/logIpc';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { sanitizeFilePath } from 'vs/base/common/extpath';
|
||||
import { GlobalStorageDatabaseChannelClient } from 'vs/platform/storage/node/storageIpc';
|
||||
|
@ -41,7 +40,6 @@ import { IFileService } from 'vs/platform/files/common/files';
|
|||
import { DiskFileSystemProvider } from 'vs/platform/files/electron-browser/diskFileSystemProvider';
|
||||
import { RemoteFileSystemProvider } from 'vs/workbench/services/remote/common/remoteAgentFileSystemChannel';
|
||||
import { ConfigurationCache } from 'vs/workbench/services/configuration/node/configurationCache';
|
||||
import { SpdLogService } from 'vs/platform/log/node/spdlogService';
|
||||
import { SignService } from 'vs/platform/sign/node/signService';
|
||||
import { ISignService } from 'vs/platform/sign/common/sign';
|
||||
import { FileUserDataProvider } from 'vs/workbench/services/userData/common/fileUserDataProvider';
|
||||
|
@ -50,6 +48,7 @@ import { IProductService } from 'vs/platform/product/common/productService';
|
|||
import product from 'vs/platform/product/common/product';
|
||||
import { NativeResourceIdentityService } from 'vs/platform/resource/node/resourceIdentityServiceImpl';
|
||||
import { IResourceIdentityService } from 'vs/platform/resource/common/resourceIdentityService';
|
||||
import { DesktopLogService } from 'vs/workbench/services/log/electron-browser/logService';
|
||||
|
||||
class DesktopMain extends Disposable {
|
||||
|
||||
|
@ -181,7 +180,7 @@ class DesktopMain extends Disposable {
|
|||
serviceCollection.set(IProductService, { _serviceBrand: undefined, ...product });
|
||||
|
||||
// Log
|
||||
const logService = this._register(this.createLogService(mainProcessService, this.environmentService));
|
||||
const logService = this._register(new DesktopLogService(this.configuration.windowId, mainProcessService, this.environmentService));
|
||||
serviceCollection.set(ILogService, logService);
|
||||
|
||||
// Remote
|
||||
|
@ -314,27 +313,6 @@ class DesktopMain extends Disposable {
|
|||
}
|
||||
}
|
||||
|
||||
private createLogService(mainProcessService: IMainProcessService, environmentService: IWorkbenchEnvironmentService): ILogService {
|
||||
const loggerClient = new LoggerChannelClient(mainProcessService.getChannel('logger'));
|
||||
|
||||
// Extension development test CLI: forward everything to main side
|
||||
const loggers: ILogService[] = [];
|
||||
if (environmentService.isExtensionDevelopment && !!environmentService.extensionTestsLocationURI) {
|
||||
loggers.push(
|
||||
new ConsoleLogInMainService(loggerClient, this.environmentService.configuration.logLevel)
|
||||
);
|
||||
}
|
||||
|
||||
// Normal logger: spdylog and console
|
||||
else {
|
||||
loggers.push(
|
||||
new ConsoleLogService(this.environmentService.configuration.logLevel),
|
||||
new SpdLogService(`renderer${this.configuration.windowId}`, environmentService.logsPath, this.environmentService.configuration.logLevel)
|
||||
);
|
||||
}
|
||||
|
||||
return new FollowerLogService(loggerClient, new MultiplexLogService(loggers));
|
||||
}
|
||||
}
|
||||
|
||||
export function main(configuration: INativeWindowConfiguration): Promise<void> {
|
||||
|
|
72
src/vs/workbench/services/log/electron-browser/logService.ts
Normal file
72
src/vs/workbench/services/log/electron-browser/logService.ts
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { DelegatedLogService, ILogService, ConsoleLogInMainService, ConsoleLogService, MultiplexLogService } from 'vs/platform/log/common/log';
|
||||
import { BufferLogService } from 'vs/platform/log/common/bufferLog';
|
||||
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
|
||||
import { IMainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
|
||||
import { LoggerChannelClient, FollowerLogService } from 'vs/platform/log/common/logIpc';
|
||||
import { SpdLogService } from 'vs/platform/log/node/spdlogService';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions } from 'vs/workbench/common/contributions';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
|
||||
export class DesktopLogService extends DelegatedLogService {
|
||||
|
||||
private readonly bufferSpdLogService: BufferLogService | undefined;
|
||||
private readonly windowId: number;
|
||||
private readonly environmentService: NativeWorkbenchEnvironmentService;
|
||||
|
||||
constructor(windowId: number, mainProcessService: IMainProcessService, environmentService: NativeWorkbenchEnvironmentService) {
|
||||
|
||||
const disposables = new DisposableStore();
|
||||
const loggerClient = new LoggerChannelClient(mainProcessService.getChannel('logger'));
|
||||
let bufferSpdLogService: BufferLogService | undefined;
|
||||
|
||||
// Extension development test CLI: forward everything to main side
|
||||
const loggers: ILogService[] = [];
|
||||
if (environmentService.isExtensionDevelopment && !!environmentService.extensionTestsLocationURI) {
|
||||
loggers.push(
|
||||
disposables.add(new ConsoleLogInMainService(loggerClient, environmentService.configuration.logLevel))
|
||||
);
|
||||
}
|
||||
|
||||
// Normal logger: spdylog and console
|
||||
else {
|
||||
bufferSpdLogService = disposables.add(new BufferLogService(environmentService.configuration.logLevel));
|
||||
loggers.push(
|
||||
disposables.add(new ConsoleLogService(environmentService.configuration.logLevel)),
|
||||
bufferSpdLogService,
|
||||
);
|
||||
}
|
||||
|
||||
const multiplexLogger = disposables.add(new MultiplexLogService(loggers));
|
||||
const followerLogger = disposables.add(new FollowerLogService(loggerClient, multiplexLogger));
|
||||
super(followerLogger);
|
||||
|
||||
this.bufferSpdLogService = bufferSpdLogService;
|
||||
this.windowId = windowId;
|
||||
this.environmentService = environmentService;
|
||||
|
||||
this._register(disposables);
|
||||
}
|
||||
|
||||
init(): void {
|
||||
if (this.bufferSpdLogService) {
|
||||
this.bufferSpdLogService.logger = this._register(new SpdLogService(`renderer${this.windowId}`, this.environmentService.logsPath, this.getLevel()));
|
||||
this.trace('Created Spdlogger');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DesktopLogServiceInitContribution implements IWorkbenchContribution {
|
||||
constructor(@ILogService logService: ILogService) {
|
||||
if (logService instanceof DesktopLogService) {
|
||||
logService.init();
|
||||
}
|
||||
}
|
||||
}
|
||||
Registry.as<IWorkbenchContributionsRegistry>(Extensions.Workbench).registerWorkbenchContribution(DesktopLogServiceInitContribution, LifecyclePhase.Restored);
|
Loading…
Reference in a new issue