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

sketch up log service

上级 32a0ba78
......@@ -109,7 +109,7 @@ export class CodeApplication {
});
app.on('will-quit', () => {
this.logService.log('App#will-quit: disposing resources');
this.logService.info('App#will-quit: disposing resources');
this.dispose();
});
......@@ -121,7 +121,7 @@ export class CodeApplication {
});
app.on('activate', (event: Event, hasVisibleWindows: boolean) => {
this.logService.log('App#activate');
this.logService.info('App#activate');
// Mac only event: open new window when we get activated
if (!hasVisibleWindows && this.windowsMainService) {
......@@ -156,7 +156,7 @@ export class CodeApplication {
let macOpenFiles: string[] = [];
let runningTimeout: number = null;
app.on('open-file', (event: Event, path: string) => {
this.logService.log('App#open-file: ', path);
this.logService.info('App#open-file: ', path);
event.preventDefault();
// Keep in array because more might come!
......@@ -188,7 +188,7 @@ export class CodeApplication {
});
ipc.on('vscode:exit', (_event: any, code: number) => {
this.logService.log('IPC#vscode:exit', code);
this.logService.info('IPC#vscode:exit', code);
this.dispose();
this.lifecycleService.kill(code);
......@@ -211,7 +211,7 @@ export class CodeApplication {
ipc.on('vscode:broadcast', (_event: any, windowId: number, broadcast: { channel: string; payload: any; }) => {
if (this.windowsMainService && broadcast.channel && !isUndefinedOrNull(broadcast.payload)) {
this.logService.log('IPC#vscode:broadcast', broadcast.channel, broadcast.payload);
this.logService.info('IPC#vscode:broadcast', broadcast.channel, broadcast.payload);
// Handle specific events on main side
this.onBroadcast(broadcast.channel, broadcast.payload);
......@@ -241,9 +241,9 @@ export class CodeApplication {
}
public startup(): TPromise<void> {
this.logService.log('Starting VS Code in verbose mode');
this.logService.log(`from: ${this.environmentService.appRoot}`);
this.logService.log('args:', this.environmentService.args);
this.logService.info('Starting VS Code in verbose mode');
this.logService.info(`from: ${this.environmentService.appRoot}`);
this.logService.info('args:', this.environmentService.args);
// Make sure we associate the program with the app user model id
// This will help Windows to associate the running program with
......@@ -257,9 +257,9 @@ export class CodeApplication {
this.electronIpcServer = new ElectronIPCServer();
// Resolve unique machine ID
this.logService.log('Resolving machine identifier...');
this.logService.info('Resolving machine identifier...');
return this.resolveMachineId().then(machineId => {
this.logService.log(`Resolved machine identifier: ${machineId}`);
this.logService.info(`Resolved machine identifier: ${machineId}`);
// Spawn shared process
this.sharedProcess = new SharedProcess(this.environmentService, machineId, this.userEnv);
......
......@@ -80,7 +80,7 @@ export class LaunchService implements ILaunchService {
) { }
public start(args: ParsedArgs, userEnv: IProcessEnvironment): TPromise<void> {
this.logService.log('Received data from other instance: ', args, userEnv);
this.logService.info('Received data from other instance: ', args, userEnv);
// Check early for open-url which is handled in URL service
const openUrlArg = args['open-url'] || [];
......@@ -127,7 +127,7 @@ export class LaunchService implements ILaunchService {
}
public getMainProcessId(): TPromise<number> {
this.logService.log('Received request for process ID from other instance.');
this.logService.info('Received request for process ID from other instance.');
return TPromise.as(process.pid);
}
......
......@@ -20,7 +20,7 @@ import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiati
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { ILogService, LogMainService } from 'vs/platform/log/common/log';
import { ILogService, LegacyLogMainService } from 'vs/platform/log/common/log';
import { StateService } from 'vs/platform/state/node/stateService';
import { IStateService } from 'vs/platform/state/common/state';
import { IBackupMainService } from 'vs/platform/backup/common/backup';
......@@ -46,7 +46,7 @@ function createServices(args: ParsedArgs): IInstantiationService {
const services = new ServiceCollection();
services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, args, process.execPath));
services.set(ILogService, new SyncDescriptor(LogMainService));
services.set(ILogService, new SyncDescriptor(LegacyLogMainService, 'main'));
services.set(IWorkspacesMainService, new SyncDescriptor(WorkspacesMainService));
services.set(IHistoryMainService, new SyncDescriptor(HistoryMainService));
services.set(ILifecycleService, new SyncDescriptor(LifecycleService));
......@@ -81,7 +81,7 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
if (platform.isWindows) {
promise = service.getMainProcessId()
.then(processId => {
logService.log('Sending some foreground love to the running instance:', processId);
logService.info('Sending some foreground love to the running instance:', processId);
try {
const { allowSetForegroundWindow } = <any>require.__$__nodeRequire('windows-foreground-love');
......@@ -125,7 +125,7 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
return TPromise.wrapError<Server>(new Error(msg));
}
logService.log('Sending env to running instance...');
logService.info('Sending env to running instance...');
// Show a warning dialog after some timeout if it takes long to talk to the other instance
// Skip this if we are running with --wait where it is expected that we wait for a while
......@@ -173,7 +173,7 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
try {
fs.unlinkSync(environmentService.mainIPCHandle);
} catch (e) {
logService.log('Fatal error deleting obsolete instance handle', e);
logService.info('Fatal error deleting obsolete instance handle', e);
return TPromise.wrapError<Server>(e);
}
......@@ -205,7 +205,7 @@ function quit(accessor: ServicesAccessor, reason?: ExpectedError | Error): void
if (reason) {
if ((reason as ExpectedError).isExpected) {
logService.log(reason.message);
logService.info(reason.message);
} else {
exitCode = 1; // signal error to the outside
......
......@@ -202,7 +202,7 @@ export class CodeWindow implements ICodeWindow {
}
}
} catch (err) {
this.logService.log(`Unexpected error fixing window position on windows with multiple windows: ${err}\n${err.stack}`);
this.logService.info(`Unexpected error fixing window position on windows with multiple windows: ${err}\n${err.stack}`);
}
}
......@@ -671,7 +671,7 @@ export class CodeWindow implements ICodeWindow {
try {
state = this.validateWindowState(state);
} catch (err) {
this.logService.log(`Unexpected error validating window state: ${err}\n${err.stack}`); // somehow display API can be picky about the state to validate
this.logService.info(`Unexpected error validating window state: ${err}\n${err.stack}`); // somehow display API can be picky about the state to validate
}
}
......
......@@ -203,7 +203,7 @@ export class WindowsManager implements IWindowsMainService {
// React to workbench loaded events from windows
ipc.on('vscode:workbenchLoaded', (_event: any, windowId: number) => {
this.logService.log('IPC#vscode-workbenchLoaded');
this.logService.info('IPC#vscode-workbenchLoaded');
const win = this.getWindowById(windowId);
if (win) {
......
......@@ -19,7 +19,7 @@ import { BackupMainService } from 'vs/platform/backup/electron-main/backupMainSe
import { IBackupWorkspacesFormat } from 'vs/platform/backup/common/backup';
import { HotExitConfiguration } from 'vs/platform/files/common/files';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { LogMainService } from 'vs/platform/log/common/log';
import { LegacyLogMainService } from 'vs/platform/log/common/log';
import { IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { createHash } from 'crypto';
import { getRandomTestPath } from 'vs/workbench/test/workbenchTestServices';
......@@ -34,7 +34,7 @@ suite('BackupMainService', () => {
class TestBackupMainService extends BackupMainService {
constructor(backupHome: string, backupWorkspacesPath: string, configService: TestConfigurationService) {
super(environmentService, configService, new LogMainService(environmentService));
super(environmentService, configService, new LegacyLogMainService('test', environmentService));
this.backupHome = backupHome;
this.workspacesJsonPath = backupWorkspacesPath;
......
......@@ -281,7 +281,7 @@ export class HistoryMainService implements IHistoryMainService {
try {
app.setJumpList(jumpList);
} catch (error) {
this.logService.log('#setJumpList', error); // since setJumpList is relatively new API, make sure to guard for errors
this.logService.info('#setJumpList', error); // since setJumpList is relatively new API, make sure to guard for errors
}
}
}
\ No newline at end of file
......@@ -124,7 +124,7 @@ export class LifecycleService implements ILifecycleService {
// before-quit
app.on('before-quit', (e) => {
this.logService.log('Lifecycle#before-quit');
this.logService.info('Lifecycle#before-quit');
if (!this.quitRequested) {
this._onBeforeQuit.fire(); // only send this if this is the first quit request we have
......@@ -135,7 +135,7 @@ export class LifecycleService implements ILifecycleService {
// window-all-closed
app.on('window-all-closed', () => {
this.logService.log('Lifecycle#window-all-closed');
this.logService.info('Lifecycle#window-all-closed');
// Windows/Linux: we quit when all windows have closed
// Mac: we only quit when quit was requested
......@@ -150,11 +150,11 @@ export class LifecycleService implements ILifecycleService {
// Window Before Closing: Main -> Renderer
window.win.on('close', e => {
const windowId = window.id;
this.logService.log('Lifecycle#window-before-close', windowId);
this.logService.info('Lifecycle#window-before-close', windowId);
// The window already acknowledged to be closed
if (this.windowToCloseRequest[windowId]) {
this.logService.log('Lifecycle#window-close', windowId);
this.logService.info('Lifecycle#window-close', windowId);
delete this.windowToCloseRequest[windowId];
......@@ -183,7 +183,7 @@ export class LifecycleService implements ILifecycleService {
return TPromise.as<boolean>(false);
}
this.logService.log('Lifecycle#unload()', window.id);
this.logService.info('Lifecycle#unload()', window.id);
const windowUnloadReason = this.quitRequested ? UnloadReason.QUIT : reason;
......@@ -247,7 +247,7 @@ export class LifecycleService implements ILifecycleService {
* by the user or not.
*/
public quit(fromUpdate?: boolean): TPromise<boolean /* veto */> {
this.logService.log('Lifecycle#quit()');
this.logService.info('Lifecycle#quit()');
if (!this.pendingQuitPromise) {
this.pendingQuitPromise = new TPromise<boolean>(c => {
......
......@@ -13,29 +13,46 @@ export const ILogService = createDecorator<ILogService>('logService');
export interface ILogService {
_serviceBrand: any;
log(...args: any[]): void;
warn(...args: any[]): void;
error(...args: any[]): void;
trace(message: string, ...args: any[]): void;
debug(message: string, ...args: any[]): void;
verbose(message: string, ...args: any[]): void;
info(message: string, ...args: any[]): void;
warn(message: string, ...args: any[]): void;
error(message: string | Error, ...args: any[]): void;
}
export class LogMainService implements ILogService {
export class LegacyLogMainService implements ILogService {
_serviceBrand: any;
constructor( @IEnvironmentService private environmentService: IEnvironmentService) {
constructor(
processName: string,
@IEnvironmentService private environmentService: IEnvironmentService
) { }
trace(message: string, ...args: any[]): void {
// console.log(`\x1b[90m[main ${new Date().toLocaleTimeString()}]\x1b[0m`, ...args);
}
debug(message: string, ...args: any[]): void {
// console.log(`\x1b[90m[main ${new Date().toLocaleTimeString()}]\x1b[0m`, ...args);
}
verbose(message: string, ...args: any[]): void {
// console.log(`\x1b[90m[main ${new Date().toLocaleTimeString()}]\x1b[0m`, ...args);
}
public log(...args: any[]): void {
info(message: string, ...args: any[]): void {
if (this.environmentService.verbose) {
console.log(`\x1b[90m[main ${new Date().toLocaleTimeString()}]\x1b[0m`, ...args);
}
}
public error(...args: any[]): void {
error(message: string, ...args: any[]): void {
console.error(`\x1b[91m[main ${new Date().toLocaleTimeString()}]\x1b[0m`, ...args);
}
public warn(...args: any[]): void {
warn(message: string | Error, ...args: any[]): void {
console.warn(`\x1b[93m[main ${new Date().toLocaleTimeString()}]\x1b[0m`, ...args);
}
}
\ No newline at end of file
......@@ -270,10 +270,10 @@ export class UpdateService implements IUpdateService {
return TPromise.as(null);
}
this.logService.log('update#quitAndInstall(): before lifecycle quit()');
this.logService.info('update#quitAndInstall(): before lifecycle quit()');
this.lifecycleService.quit(true /* from update */).done(vetod => {
this.logService.log(`update#quitAndInstall(): after lifecycle quit() with veto: ${vetod}`);
this.logService.info(`update#quitAndInstall(): after lifecycle quit() with veto: ${vetod}`);
if (vetod) {
return;
}
......@@ -282,11 +282,11 @@ export class UpdateService implements IUpdateService {
// we workaround this issue by forcing an explicit flush of the storage data.
// see also https://github.com/Microsoft/vscode/issues/172
if (process.platform === 'darwin') {
this.logService.log('update#quitAndInstall(): calling flushStorageData()');
this.logService.info('update#quitAndInstall(): calling flushStorageData()');
electron.session.defaultSession.flushStorageData();
}
this.logService.log('update#quitAndInstall(): running raw#quitAndInstall()');
this.logService.info('update#quitAndInstall(): running raw#quitAndInstall()');
this.raw.quitAndInstall();
});
......
......@@ -86,7 +86,7 @@ export class WorkspacesMainService implements IWorkspacesMainService {
folders: toWorkspaceFolders(workspace.folders, URI.file(dirname(path)))
};
} catch (error) {
this.logService.log(error.toString());
this.logService.info(error.toString());
}
return null;
......@@ -262,7 +262,7 @@ export class WorkspacesMainService implements IWorkspacesMainService {
try {
delSync(dirname(configPath));
} catch (error) {
this.logService.log(`Unable to delete untitled workspace ${configPath} (${error}).`);
this.logService.info(`Unable to delete untitled workspace ${configPath} (${error}).`);
}
}
......@@ -271,7 +271,7 @@ export class WorkspacesMainService implements IWorkspacesMainService {
try {
untitledWorkspacePaths = readdirSync(this.workspacesHome).map(folder => join(this.workspacesHome, folder, UNTITLED_WORKSPACE_NAME));
} catch (error) {
this.logService.log(`Unable to read folders in ${this.workspacesHome} (${error}).`);
this.logService.info(`Unable to read folders in ${this.workspacesHome} (${error}).`);
}
const untitledWorkspaces: IWorkspaceIdentifier[] = coalesce(untitledWorkspacePaths.map(untitledWorkspacePath => {
......
......@@ -15,7 +15,7 @@ import { EnvironmentService } from 'vs/platform/environment/node/environmentServ
import { parseArgs } from 'vs/platform/environment/node/argv';
import { WorkspacesMainService, IStoredWorkspace } from 'vs/platform/workspaces/electron-main/workspacesMainService';
import { WORKSPACE_EXTENSION, IWorkspaceSavedEvent, IWorkspaceIdentifier, IRawFileWorkspaceFolder, IWorkspaceFolderCreationData, IRawUriWorkspaceFolder } from 'vs/platform/workspaces/common/workspaces';
import { LogMainService } from 'vs/platform/log/common/log';
import { LegacyLogMainService } from 'vs/platform/log/common/log';
import URI from 'vs/base/common/uri';
import { getRandomTestPath } from 'vs/workbench/test/workbenchTestServices';
......@@ -48,7 +48,7 @@ suite('WorkspacesMainService', () => {
}
const environmentService = new TestEnvironmentService(parseArgs(process.argv), process.execPath);
const logService = new LogMainService(environmentService);
const logService = new LegacyLogMainService('test', environmentService);
let service: TestWorkspacesMainService;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册