Path: blob/main/src/vs/workbench/contrib/logs/electron-browser/logsActions.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Action } from '../../../../base/common/actions.js';6import * as nls from '../../../../nls.js';7import { INativeHostService } from '../../../../platform/native/common/native.js';8import { INativeWorkbenchEnvironmentService } from '../../../services/environment/electron-browser/environmentService.js';9import { IFileService } from '../../../../platform/files/common/files.js';10import { joinPath } from '../../../../base/common/resources.js';11import { Schemas } from '../../../../base/common/network.js';1213export class OpenLogsFolderAction extends Action {1415static readonly ID = 'workbench.action.openLogsFolder';16static readonly TITLE = nls.localize2('openLogsFolder', "Open Logs Folder");1718constructor(id: string, label: string,19@INativeWorkbenchEnvironmentService private readonly environmentService: INativeWorkbenchEnvironmentService,20@INativeHostService private readonly nativeHostService: INativeHostService,21) {22super(id, label);23}2425override run(): Promise<void> {26return this.nativeHostService.showItemInFolder(joinPath(this.environmentService.logsHome, 'main.log').with({ scheme: Schemas.file }).fsPath);27}28}2930export class OpenExtensionLogsFolderAction extends Action {3132static readonly ID = 'workbench.action.openExtensionLogsFolder';33static readonly TITLE = nls.localize2('openExtensionLogsFolder', "Open Extension Logs Folder");3435constructor(id: string, label: string,36@INativeWorkbenchEnvironmentService private readonly environmentSerice: INativeWorkbenchEnvironmentService,37@IFileService private readonly fileService: IFileService,38@INativeHostService private readonly nativeHostService: INativeHostService39) {40super(id, label);41}4243override async run(): Promise<void> {44const folderStat = await this.fileService.resolve(this.environmentSerice.extHostLogsPath);45if (folderStat.children && folderStat.children[0]) {46return this.nativeHostService.showItemInFolder(folderStat.children[0].resource.with({ scheme: Schemas.file }).fsPath);47}48}49}505152