提交 22878854 编写于 作者: J Joao Moreno

env & log service

上级 b1df68a4
......@@ -17,6 +17,31 @@ import paths = require('vs/base/common/paths');
import platform = require('vs/base/common/platform');
import uri from 'vs/base/common/uri';
import types = require('vs/base/common/types');
import {ServiceIdentifier, createDecorator} from 'vs/platform/instantiation/common/instantiation';
export interface IEnv {
cliArgs: ICommandLineArguments;
}
export const IEnvService = createDecorator<IEnvService>('environmentService');
export interface IEnvService {
serviceId: ServiceIdentifier<any>;
getEnv(): IEnv;
}
export class EnvService implements IEnvService {
serviceId = IEnvService;
constructor() {
}
getEnv(): IEnv {
return null;
}
}
export interface IProductConfiguration {
nameShort: string;
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {ServiceIdentifier, createDecorator} from 'vs/platform/instantiation/common/instantiation';
import {IEnvService} from './env';
export const ILogService = createDecorator<ILogService>('logService');
export interface ILogService {
serviceId: ServiceIdentifier<any>;
log(... args: any[]): void;
}
export class MainLogService implements ILogService {
serviceId = ILogService;
constructor(@IEnvService private envService: IEnvService) {
}
log(...args: any[]): void {
const { cliArgs } = this.envService.getEnv();
if (cliArgs.verboseLogging) {
console.log.call(null, `(${new Date().toLocaleTimeString()})`, ...args);
}
}
}
\ No newline at end of file
......@@ -24,6 +24,10 @@ import {GitAskpassService} from 'vs/workbench/parts/git/electron-main/askpassSer
import {spawnSharedProcess} from 'vs/workbench/electron-main/sharedProcess';
import {Mutex} from 'windows-mutex';
import {LaunchService, ILaunchChannel, LaunchChannel, LaunchChannelClient} from './launch';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import {InstantiationService} from 'vs/platform/instantiation/common/instantiationService';
import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollection';
import {ILogService, MainLogService} from './log';
// We handle uncaught exceptions here to prevent electron from opening a dialog to the user
process.on('uncaughtException', (err: any) => {
......@@ -63,6 +67,16 @@ function quit(arg?: any) {
process.exit(exitCode); // in main, process.exit === app.exit
}
export function createServices(): IInstantiationService {
const services = new ServiceCollection();
const envService = new env.EnvService();
services.set(env.IEnvService, envService);
services.set(ILogService, new MainLogService(envService));
return new InstantiationService(services);
}
function main(ipcServer: Server, userEnv: env.IProcessEnvironment): void {
env.log('### VSCode main.js ###');
env.log(env.appRoot, env.cliArgs);
......@@ -76,6 +90,9 @@ function main(ipcServer: Server, userEnv: env.IProcessEnvironment): void {
// noop
}
const instantiationService = createServices();
instantiationService.invokeFunction(() => {});
// Register IPC services
const launchService = new LaunchService();
const launchChannel = new LaunchChannel(launchService);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册