logsActions.ts 2.2 KB
Newer Older
1 2 3 4 5 6 7 8
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import { Action } from 'vs/base/common/actions';
import { join } from 'vs/base/common/path';
import { URI } from 'vs/base/common/uri';
9
import * as nls from 'vs/nls';
10
import { IElectronService } from 'vs/platform/electron/electron-sandbox/electron';
11 12
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
13
import { IFileService } from 'vs/platform/files/common/files';
14 15 16

export class OpenLogsFolderAction extends Action {

17 18
	static readonly ID = 'workbench.action.openLogsFolder';
	static readonly LABEL = nls.localize('openLogsFolder', "Open Logs Folder");
19 20

	constructor(id: string, label: string,
21
		@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
22 23 24 25 26 27 28 29 30
		@IElectronService private readonly electronService: IElectronService,
	) {
		super(id, label);
	}

	run(): Promise<void> {
		return this.electronService.showItemInFolder(URI.file(join(this.environmentService.logsPath, 'main.log')).fsPath);
	}
}
31 32 33 34 35 36 37

export class OpenExtensionLogsFolderAction extends Action {

	static readonly ID = 'workbench.action.openExtensionLogsFolder';
	static readonly LABEL = nls.localize('openExtensionLogsFolder', "Open Extension Logs Folder");

	constructor(id: string, label: string,
38
		@IWorkbenchEnvironmentService private readonly environmentSerice: INativeWorkbenchEnvironmentService,
39 40
		@IFileService private readonly fileService: IFileService,
		@IElectronService private readonly electronService: IElectronService
41 42 43 44
	) {
		super(id, label);
	}

45
	async run(): Promise<void> {
46
		const folderStat = await this.fileService.resolve(this.environmentSerice.extHostLogsPath);
47 48 49
		if (folderStat.children && folderStat.children[0]) {
			return this.electronService.showItemInFolder(folderStat.children[0].resource.fsPath);
		}
50 51
	}
}