Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/logs/electron-browser/logsActions.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Action } from '../../../../base/common/actions.js';
7
import * as nls from '../../../../nls.js';
8
import { INativeHostService } from '../../../../platform/native/common/native.js';
9
import { INativeWorkbenchEnvironmentService } from '../../../services/environment/electron-browser/environmentService.js';
10
import { IFileService } from '../../../../platform/files/common/files.js';
11
import { joinPath } from '../../../../base/common/resources.js';
12
import { Schemas } from '../../../../base/common/network.js';
13
14
export class OpenLogsFolderAction extends Action {
15
16
static readonly ID = 'workbench.action.openLogsFolder';
17
static readonly TITLE = nls.localize2('openLogsFolder', "Open Logs Folder");
18
19
constructor(id: string, label: string,
20
@INativeWorkbenchEnvironmentService private readonly environmentService: INativeWorkbenchEnvironmentService,
21
@INativeHostService private readonly nativeHostService: INativeHostService,
22
) {
23
super(id, label);
24
}
25
26
override run(): Promise<void> {
27
return this.nativeHostService.showItemInFolder(joinPath(this.environmentService.logsHome, 'main.log').with({ scheme: Schemas.file }).fsPath);
28
}
29
}
30
31
export class OpenExtensionLogsFolderAction extends Action {
32
33
static readonly ID = 'workbench.action.openExtensionLogsFolder';
34
static readonly TITLE = nls.localize2('openExtensionLogsFolder', "Open Extension Logs Folder");
35
36
constructor(id: string, label: string,
37
@INativeWorkbenchEnvironmentService private readonly environmentSerice: INativeWorkbenchEnvironmentService,
38
@IFileService private readonly fileService: IFileService,
39
@INativeHostService private readonly nativeHostService: INativeHostService
40
) {
41
super(id, label);
42
}
43
44
override async run(): Promise<void> {
45
const folderStat = await this.fileService.resolve(this.environmentSerice.extHostLogsPath);
46
if (folderStat.children && folderStat.children[0]) {
47
return this.nativeHostService.showItemInFolder(folderStat.children[0].resource.with({ scheme: Schemas.file }).fsPath);
48
}
49
}
50
}
51
52