@codingame/monaco-vscode-log-service-override 3.2.2 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-log-service-override",
3
- "version": "3.2.2",
3
+ "version": "4.0.0",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -18,7 +18,7 @@
18
18
  "module": "index.js",
19
19
  "types": "index.d.ts",
20
20
  "dependencies": {
21
- "vscode": "npm:@codingame/monaco-vscode-api@3.2.2",
22
- "@codingame/monaco-vscode-environment-service-override": "3.2.2"
21
+ "vscode": "npm:@codingame/monaco-vscode-api@4.0.0",
22
+ "@codingame/monaco-vscode-environment-service-override": "4.0.0"
23
23
  }
24
24
  }
@@ -3,7 +3,7 @@ import { localize2WithPath, localizeWithPath } from 'vscode/vscode/vs/nls';
3
3
  import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
4
4
  import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommonCategories';
5
5
  import { registerAction2, Action2 } from 'vscode/vscode/vs/platform/actions/common/actions';
6
- import { SetLogLevelAction } from './logsActions.js';
6
+ import { SetLogLevelAction } from 'vscode/vscode/vs/workbench/contrib/logs/common/logsActions';
7
7
  import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
8
8
  import { whenProviderRegistered, IFileService } from 'vscode/vscode/vs/platform/files/common/files';
9
9
  import { Extensions as Extensions$1, IOutputService } from 'vscode/vscode/vs/workbench/services/output/common/output';
@@ -187,7 +187,7 @@ let LogOutputChannels = class LogOutputChannels extends Disposable {
187
187
  await this.whenFileExists(file, trial + 1, token);
188
188
  }
189
189
  registerShowWindowLogAction() {
190
- registerAction2(class ShowWindowLogAction extends Action2 {
190
+ this._register(registerAction2(class ShowWindowLogAction extends Action2 {
191
191
  constructor() {
192
192
  super({
193
193
  id: showWindowLogActionId,
@@ -204,7 +204,7 @@ let LogOutputChannels = class LogOutputChannels extends Disposable {
204
204
  const outputService = servicesAccessor.get(IOutputService);
205
205
  outputService.showChannel(windowLogId);
206
206
  }
207
- });
207
+ }));
208
208
  }
209
209
  };
210
210
  LogOutputChannels = ( __decorate([
@@ -1,250 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { localize2WithPath, localizeWithPath } from 'vscode/vscode/vs/nls';
3
- import { Action } from 'vscode/vscode/vs/base/common/actions';
4
- import { isLogLevel, LogLevel, ILoggerService } from 'vscode/vscode/vs/platform/log/common/log';
5
- import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput';
6
- import { URI } from 'vscode/vscode/vs/base/common/uri';
7
- import { basename, dirname, isEqual } from 'vscode/vscode/vs/base/common/resources';
8
- import { IOutputService } from 'vscode/vscode/vs/workbench/services/output/common/output';
9
- import { telemetryLogId, extensionTelemetryLogChannelId } from 'vscode/vscode/vs/platform/telemetry/common/telemetryUtils';
10
- import { IDefaultLogLevelsService } from 'vscode/vscode/vs/workbench/contrib/logs/common/defaultLogLevels';
11
- import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
12
- import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
13
- import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
14
-
15
- let SetLogLevelAction = class SetLogLevelAction extends Action {
16
- static { this.ID = 'workbench.action.setLogLevel'; }
17
- static { this.TITLE = ( localize2WithPath(
18
- 'vs/workbench/contrib/logs/common/logsActions',
19
- 'setLogLevel',
20
- "Set Log Level..."
21
- )); }
22
- constructor(id, label, quickInputService, loggerService, outputService, defaultLogLevelsService) {
23
- super(id, label);
24
- this.quickInputService = quickInputService;
25
- this.loggerService = loggerService;
26
- this.outputService = outputService;
27
- this.defaultLogLevelsService = defaultLogLevelsService;
28
- }
29
- async run() {
30
- const logLevelOrChannel = await this.selectLogLevelOrChannel();
31
- if (logLevelOrChannel !== null) {
32
- if (isLogLevel(logLevelOrChannel)) {
33
- this.loggerService.setLogLevel(logLevelOrChannel);
34
- }
35
- else {
36
- await this.setLogLevelForChannel(logLevelOrChannel);
37
- }
38
- }
39
- }
40
- async selectLogLevelOrChannel() {
41
- const defaultLogLevels = await this.defaultLogLevelsService.getDefaultLogLevels();
42
- const extensionLogs = [], logs = [];
43
- const logLevel = this.loggerService.getLogLevel();
44
- for (const channel of this.outputService.getChannelDescriptors()) {
45
- if (!channel.log || !channel.file || channel.id === telemetryLogId || channel.id === extensionTelemetryLogChannelId) {
46
- continue;
47
- }
48
- const channelLogLevel = this.loggerService.getLogLevel(channel.file) ?? logLevel;
49
- const item = { id: channel.id, resource: channel.file, label: channel.label, description: channelLogLevel !== logLevel ? this.getLabel(channelLogLevel) : undefined, extensionId: channel.extensionId };
50
- if (channel.extensionId) {
51
- extensionLogs.push(item);
52
- }
53
- else {
54
- logs.push(item);
55
- }
56
- }
57
- const entries = [];
58
- entries.push({ type: 'separator', label: ( localizeWithPath('vs/workbench/contrib/logs/common/logsActions', 'all', "All")) });
59
- entries.push(...this.getLogLevelEntries(defaultLogLevels.default, this.loggerService.getLogLevel(), true));
60
- if (extensionLogs.length) {
61
- entries.push({ type: 'separator', label: ( localizeWithPath(
62
- 'vs/workbench/contrib/logs/common/logsActions',
63
- 'extensionLogs',
64
- "Extension Logs"
65
- )) });
66
- entries.push(...extensionLogs.sort((a, b) => a.label.localeCompare(b.label)));
67
- }
68
- entries.push({ type: 'separator', label: ( localizeWithPath('vs/workbench/contrib/logs/common/logsActions', 'loggers', "Logs")) });
69
- entries.push(...logs.sort((a, b) => a.label.localeCompare(b.label)));
70
- return ( new Promise((resolve, reject) => {
71
- const disposables = ( new DisposableStore());
72
- const quickPick = this.quickInputService.createQuickPick();
73
- quickPick.placeholder = ( localizeWithPath(
74
- 'vs/workbench/contrib/logs/common/logsActions',
75
- 'selectlog',
76
- "Set Log Level"
77
- ));
78
- quickPick.items = entries;
79
- let selectedItem;
80
- disposables.add(quickPick.onDidTriggerItemButton(e => {
81
- quickPick.hide();
82
- this.defaultLogLevelsService.setDefaultLogLevel(e.item.level);
83
- }));
84
- disposables.add(quickPick.onDidAccept(e => {
85
- selectedItem = quickPick.selectedItems[0];
86
- quickPick.hide();
87
- }));
88
- disposables.add(quickPick.onDidHide(() => {
89
- const result = selectedItem ? selectedItem.level ?? selectedItem : null;
90
- disposables.dispose();
91
- resolve(result);
92
- }));
93
- quickPick.show();
94
- }));
95
- }
96
- async setLogLevelForChannel(logChannel) {
97
- const defaultLogLevels = await this.defaultLogLevelsService.getDefaultLogLevels();
98
- const defaultLogLevel = defaultLogLevels.extensions.find(e => e[0] === logChannel.extensionId?.toLowerCase())?.[1] ?? defaultLogLevels.default;
99
- const currentLogLevel = this.loggerService.getLogLevel(logChannel.resource) ?? defaultLogLevel;
100
- const entries = this.getLogLevelEntries(defaultLogLevel, currentLogLevel, !!logChannel.extensionId);
101
- return ( new Promise((resolve, reject) => {
102
- const disposables = ( new DisposableStore());
103
- const quickPick = this.quickInputService.createQuickPick();
104
- quickPick.placeholder = logChannel ? ( localizeWithPath(
105
- 'vs/workbench/contrib/logs/common/logsActions',
106
- 'selectLogLevelFor',
107
- " {0}: Select log level",
108
- logChannel?.label
109
- )) : ( localizeWithPath(
110
- 'vs/workbench/contrib/logs/common/logsActions',
111
- 'selectLogLevel',
112
- "Select log level"
113
- ));
114
- quickPick.items = entries;
115
- quickPick.activeItems = entries.filter((entry) => entry.level === this.loggerService.getLogLevel());
116
- let selectedItem;
117
- disposables.add(quickPick.onDidTriggerItemButton(e => {
118
- quickPick.hide();
119
- this.defaultLogLevelsService.setDefaultLogLevel(e.item.level, logChannel.extensionId);
120
- }));
121
- disposables.add(quickPick.onDidAccept(e => {
122
- selectedItem = quickPick.selectedItems[0];
123
- quickPick.hide();
124
- }));
125
- disposables.add(quickPick.onDidHide(() => {
126
- if (selectedItem) {
127
- this.loggerService.setLogLevel(logChannel.resource, selectedItem.level);
128
- }
129
- disposables.dispose();
130
- resolve();
131
- }));
132
- quickPick.show();
133
- }));
134
- }
135
- getLogLevelEntries(defaultLogLevel, currentLogLevel, canSetDefaultLogLevel) {
136
- const button = canSetDefaultLogLevel ? { iconClass: ThemeIcon.asClassName(Codicon.checkAll), tooltip: ( localizeWithPath(
137
- 'vs/workbench/contrib/logs/common/logsActions',
138
- 'resetLogLevel',
139
- "Set as Default Log Level"
140
- )) } : undefined;
141
- return [
142
- { label: this.getLabel(LogLevel.Trace, currentLogLevel), level: LogLevel.Trace, description: this.getDescription(LogLevel.Trace, defaultLogLevel), buttons: button && defaultLogLevel !== LogLevel.Trace ? [button] : undefined },
143
- { label: this.getLabel(LogLevel.Debug, currentLogLevel), level: LogLevel.Debug, description: this.getDescription(LogLevel.Debug, defaultLogLevel), buttons: button && defaultLogLevel !== LogLevel.Debug ? [button] : undefined },
144
- { label: this.getLabel(LogLevel.Info, currentLogLevel), level: LogLevel.Info, description: this.getDescription(LogLevel.Info, defaultLogLevel), buttons: button && defaultLogLevel !== LogLevel.Info ? [button] : undefined },
145
- { label: this.getLabel(LogLevel.Warning, currentLogLevel), level: LogLevel.Warning, description: this.getDescription(LogLevel.Warning, defaultLogLevel), buttons: button && defaultLogLevel !== LogLevel.Warning ? [button] : undefined },
146
- { label: this.getLabel(LogLevel.Error, currentLogLevel), level: LogLevel.Error, description: this.getDescription(LogLevel.Error, defaultLogLevel), buttons: button && defaultLogLevel !== LogLevel.Error ? [button] : undefined },
147
- { label: this.getLabel(LogLevel.Off, currentLogLevel), level: LogLevel.Off, description: this.getDescription(LogLevel.Off, defaultLogLevel), buttons: button && defaultLogLevel !== LogLevel.Off ? [button] : undefined },
148
- ];
149
- }
150
- getLabel(level, current) {
151
- let label;
152
- switch (level) {
153
- case LogLevel.Trace:
154
- label = ( localizeWithPath('vs/workbench/contrib/logs/common/logsActions', 'trace', "Trace"));
155
- break;
156
- case LogLevel.Debug:
157
- label = ( localizeWithPath('vs/workbench/contrib/logs/common/logsActions', 'debug', "Debug"));
158
- break;
159
- case LogLevel.Info:
160
- label = ( localizeWithPath('vs/workbench/contrib/logs/common/logsActions', 'info', "Info"));
161
- break;
162
- case LogLevel.Warning:
163
- label = ( localizeWithPath('vs/workbench/contrib/logs/common/logsActions', 'warn', "Warning"));
164
- break;
165
- case LogLevel.Error:
166
- label = ( localizeWithPath('vs/workbench/contrib/logs/common/logsActions', 'err', "Error"));
167
- break;
168
- case LogLevel.Off:
169
- label = ( localizeWithPath('vs/workbench/contrib/logs/common/logsActions', 'off', "Off"));
170
- break;
171
- }
172
- return level === current ? `$(check) ${label}` : label;
173
- }
174
- getDescription(level, defaultLogLevel) {
175
- return defaultLogLevel === level ? ( localizeWithPath('vs/workbench/contrib/logs/common/logsActions', 'default', "Default")) : undefined;
176
- }
177
- };
178
- SetLogLevelAction = ( __decorate([
179
- ( __param(2, IQuickInputService)),
180
- ( __param(3, ILoggerService)),
181
- ( __param(4, IOutputService)),
182
- ( __param(5, IDefaultLogLevelsService))
183
- ], SetLogLevelAction));
184
- (class OpenWindowSessionLogFileAction extends Action {
185
- static { this.ID = 'workbench.action.openSessionLogFile'; }
186
- static { this.TITLE = ( localize2WithPath(
187
- 'vs/workbench/contrib/logs/common/logsActions',
188
- 'openSessionLogFile',
189
- "Open Window Log File (Session)..."
190
- )); }
191
- constructor(id, label, environmentService, fileService, quickInputService, editorService) {
192
- super(id, label);
193
- this.environmentService = environmentService;
194
- this.fileService = fileService;
195
- this.quickInputService = quickInputService;
196
- this.editorService = editorService;
197
- }
198
- async run() {
199
- const sessionResult = await this.quickInputService.pick(this.getSessions().then(sessions => ( sessions.map((s, index) => ({
200
- id: ( s.toString()),
201
- label: basename(s),
202
- description: index === 0 ? ( localizeWithPath('vs/workbench/contrib/logs/common/logsActions', 'current', "Current")) : undefined
203
- })))), {
204
- canPickMany: false,
205
- placeHolder: ( localizeWithPath(
206
- 'vs/workbench/contrib/logs/common/logsActions',
207
- 'sessions placeholder',
208
- "Select Session"
209
- ))
210
- });
211
- if (sessionResult) {
212
- const logFileResult = await this.quickInputService.pick(this.getLogFiles(( URI.parse(sessionResult.id))).then(logFiles => ( logFiles.map(s => ({
213
- id: ( s.toString()),
214
- label: basename(s)
215
- })))), {
216
- canPickMany: false,
217
- placeHolder: ( localizeWithPath(
218
- 'vs/workbench/contrib/logs/common/logsActions',
219
- 'log placeholder',
220
- "Select Log file"
221
- ))
222
- });
223
- if (logFileResult) {
224
- return this.editorService.openEditor({ resource: ( URI.parse(logFileResult.id)), options: { pinned: true } }).then(() => undefined);
225
- }
226
- }
227
- }
228
- async getSessions() {
229
- const logsPath = this.environmentService.logsHome.with({ scheme: this.environmentService.logFile.scheme });
230
- const result = [logsPath];
231
- const stat = await this.fileService.resolve(dirname(logsPath));
232
- if (stat.children) {
233
- result.push(...( stat.children
234
- .filter(stat => !isEqual(stat.resource, logsPath) && stat.isDirectory && /^\d{8}T\d{6}$/.test(stat.name))
235
- .sort()
236
- .reverse()
237
- .map(d => d.resource)));
238
- }
239
- return result;
240
- }
241
- async getLogFiles(session) {
242
- const stat = await this.fileService.resolve(session);
243
- if (stat.children) {
244
- return ( stat.children.filter(stat => !stat.isDirectory).map(stat => stat.resource));
245
- }
246
- return [];
247
- }
248
- });
249
-
250
- export { SetLogLevelAction };