mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
parent
65cd84391d
commit
d8cacdc1fd
|
@ -37,7 +37,7 @@
|
|||
"node-pty": "0.7.3",
|
||||
"nsfw": "1.0.16",
|
||||
"semver": "4.3.6",
|
||||
"spdlog": "0.2.1",
|
||||
"spdlog": "0.3.0",
|
||||
"v8-inspect-profiler": "^0.0.6",
|
||||
"vscode-chokidar": "1.6.2",
|
||||
"vscode-debugprotocol": "1.25.0",
|
||||
|
@ -127,4 +127,4 @@
|
|||
"windows-mutex": "^0.2.0",
|
||||
"windows-process-tree": "0.1.6"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
1
src/typings/spdlog.d.ts
vendored
1
src/typings/spdlog.d.ts
vendored
|
@ -29,5 +29,6 @@ declare module 'spdlog' {
|
|||
critical(message: string);
|
||||
setLevel(level: number);
|
||||
flush(): void;
|
||||
drop(): void;
|
||||
}
|
||||
}
|
|
@ -80,6 +80,7 @@ function main(server: Server, initData: ISharedProcessInitData, configuration: I
|
|||
|
||||
const environmentService = new EnvironmentService(initData.args, process.execPath);
|
||||
const logService = new SpdLogService('sharedprocess', environmentService);
|
||||
process.once('exit', () => logService.dispose());
|
||||
registerGlobalLogService(logService);
|
||||
|
||||
logService.info('main', JSON.stringify(configuration));
|
||||
|
|
|
@ -51,7 +51,9 @@ function createServices(args: ParsedArgs): IInstantiationService {
|
|||
const spdlogService = new SpdLogService('main', environmentService);
|
||||
const legacyLogService = new LegacyLogMainService(environmentService);
|
||||
const logService = new MultiplexLogService([legacyLogService, spdlogService]);
|
||||
|
||||
registerGlobalLogService(logService);
|
||||
process.once('exit', () => logService.dispose());
|
||||
|
||||
// Eventually cleanup
|
||||
setTimeout(() => spdlogService.cleanup().then(null, err => console.error(err)), 10000);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { createDecorator as createServiceDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { createDecorator } from 'vs/base/common/decorators';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
export const ILogService = createServiceDecorator<ILogService>('logService');
|
||||
|
||||
|
@ -21,7 +22,7 @@ export enum LogLevel {
|
|||
Off
|
||||
}
|
||||
|
||||
export interface ILogService {
|
||||
export interface ILogService extends IDisposable {
|
||||
_serviceBrand: any;
|
||||
|
||||
setLevel(level: LogLevel): void;
|
||||
|
@ -81,6 +82,10 @@ export class LegacyLogMainService implements ILogService {
|
|||
console.error(`\x1b[90m[main ${new Date().toLocaleTimeString()}]\x1b[0m`, message, ...args);
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
|
||||
export class MultiplexLogService implements ILogService {
|
||||
|
@ -129,6 +134,12 @@ export class MultiplexLogService implements ILogService {
|
|||
logService.critical(message, ...args);
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
for (const logService of this.logServices) {
|
||||
logService.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class NoopLogService implements ILogService {
|
||||
|
@ -140,6 +151,7 @@ export class NoopLogService implements ILogService {
|
|||
warn(message: string, ...args: any[]): void { }
|
||||
error(message: string | Error, ...args: any[]): void { }
|
||||
critical(message: string | Error, ...args: any[]): void { }
|
||||
dispose(): void { }
|
||||
}
|
||||
|
||||
let globalLogService: ILogService = new NoopLogService();
|
||||
|
|
|
@ -10,7 +10,6 @@ import { ILogService, LogLevel } from 'vs/platform/log/common/log';
|
|||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { RotatingLogger, setAsyncMode } from 'spdlog';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { fromNodeEventEmitter } from 'vs/base/common/event';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { readdir, rimraf } from 'vs/base/node/pfs';
|
||||
|
||||
|
@ -30,8 +29,6 @@ export class SpdLogService implements ILogService {
|
|||
const logfilePath = path.join(environmentService.logsPath, `${processName}.log`);
|
||||
this.logger = new RotatingLogger(processName, logfilePath, 1024 * 1024 * 5, 6);
|
||||
this.setLevel(environmentService.logLevel);
|
||||
|
||||
fromNodeEventEmitter(process, 'exit')(() => this.logger.flush(), null, this.disposables);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,6 +76,8 @@ export class SpdLogService implements ILogService {
|
|||
}
|
||||
|
||||
dispose(): void {
|
||||
this.logger.flush();
|
||||
this.logger.drop();
|
||||
this.disposables = dispose(this.disposables);
|
||||
}
|
||||
|
||||
|
|
|
@ -287,6 +287,8 @@ export class WorkbenchShell {
|
|||
serviceCollection.set(IConfigurationService, this.configurationService);
|
||||
serviceCollection.set(IEnvironmentService, this.environmentService);
|
||||
serviceCollection.set(ILogService, this.logService);
|
||||
disposables.push(this.logService);
|
||||
|
||||
serviceCollection.set(ITimerService, this.timerService);
|
||||
serviceCollection.set(IStorageService, this.storageService);
|
||||
this.mainProcessServices.forEach((serviceIdentifier, serviceInstance) => {
|
||||
|
|
|
@ -25,6 +25,7 @@ import { ExtensionActivatedByEvent } from 'vs/workbench/api/node/extHostExtensio
|
|||
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { SpdLogService } from 'vs/platform/log/node/spdlogService';
|
||||
import { registerGlobalLogService } from 'vs/platform/log/common/log';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
|
||||
// const nativeExit = process.exit.bind(process);
|
||||
function patchProcess(allowExit: boolean) {
|
||||
|
@ -76,6 +77,7 @@ export class ExtensionHostMain {
|
|||
private _environment: IEnvironment;
|
||||
private _extensionService: ExtHostExtensionService;
|
||||
private _extHostConfiguration: ExtHostConfiguration;
|
||||
private disposables: IDisposable[] = [];
|
||||
|
||||
constructor(rpcProtocol: RPCProtocol, initData: IInitData) {
|
||||
this._environment = initData.environment;
|
||||
|
@ -89,7 +91,9 @@ export class ExtensionHostMain {
|
|||
const extHostWorkspace = new ExtHostWorkspace(threadService, initData.workspace);
|
||||
const environmentService = new EnvironmentService(initData.args, initData.execPath);
|
||||
const logService = new SpdLogService(`exthost${initData.windowId}`, environmentService);
|
||||
|
||||
registerGlobalLogService(logService);
|
||||
this.disposables.push(logService);
|
||||
|
||||
logService.info('main {0}', initData);
|
||||
|
||||
|
@ -146,6 +150,8 @@ export class ExtensionHostMain {
|
|||
}
|
||||
this._isTerminating = true;
|
||||
|
||||
this.disposables = dispose(this.disposables);
|
||||
|
||||
errors.setUnexpectedErrorHandler((err) => {
|
||||
// TODO: write to log once we have one
|
||||
});
|
||||
|
|
|
@ -5038,9 +5038,9 @@ sparkles@^1.0.0:
|
|||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.0.tgz#1acbbfb592436d10bbe8f785b7cc6f82815012c3"
|
||||
|
||||
spdlog@0.2.1:
|
||||
version "0.2.1"
|
||||
resolved "https://registry.yarnpkg.com/spdlog/-/spdlog-0.2.1.tgz#1a9de952ccffe9b9227dd20306aca7e428621fa1"
|
||||
spdlog@0.3.0:
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/spdlog/-/spdlog-0.3.0.tgz#8fc0dfa407ccb97854bd026beb91267adeed5cf3"
|
||||
dependencies:
|
||||
bindings "^1.3.0"
|
||||
mkdirp "^0.5.1"
|
||||
|
|
Loading…
Reference in a new issue