@codingame/monaco-vscode-log-service-override 13.1.6 → 14.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 +5 -6
- package/vscode/src/vs/workbench/contrib/logs/common/defaultLogLevels.d.ts +0 -1
- package/vscode/src/vs/workbench/contrib/logs/common/defaultLogLevels.js +0 -10
- package/vscode/src/vs/workbench/contrib/logs/common/logs.contribution.js +44 -69
- package/vscode/src/vs/workbench/contrib/logs/common/logsActions.d.ts +36 -0
- package/vscode/src/vs/workbench/contrib/logs/common/logsActions.js +204 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-log-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - log service-override",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,11 +15,10 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-
|
|
19
|
-
"@codingame/monaco-vscode-
|
|
20
|
-
"@codingame/monaco-vscode-
|
|
21
|
-
"@codingame/monaco-vscode-
|
|
22
|
-
"@codingame/monaco-vscode-environment-service-override": "13.1.6"
|
|
18
|
+
"@codingame/monaco-vscode-abed5a84-8a82-5f84-9412-88a736235bae-common": "14.0.0",
|
|
19
|
+
"@codingame/monaco-vscode-api": "14.0.0",
|
|
20
|
+
"@codingame/monaco-vscode-cea4d01f-6526-5c2f-8b09-b168fead499f-common": "14.0.0",
|
|
21
|
+
"@codingame/monaco-vscode-environment-service-override": "14.0.0"
|
|
23
22
|
},
|
|
24
23
|
"main": "index.js",
|
|
25
24
|
"module": "index.js",
|
|
@@ -30,7 +30,6 @@ export declare class DefaultLogLevelsService extends Disposable implements IDefa
|
|
|
30
30
|
private _getDefaultLogLevel;
|
|
31
31
|
private _writeLogLevelsToArgv;
|
|
32
32
|
private _parseLogLevelsFromArgv;
|
|
33
|
-
migrateLogLevels(): Promise<void>;
|
|
34
33
|
private _readLogLevelsFromArgv;
|
|
35
34
|
private _getDefaultLogLevelFromEnv;
|
|
36
35
|
private _getExtensionsDefaultLogLevelsFromEnv;
|
|
@@ -112,16 +112,6 @@ let DefaultLogLevelsService = class DefaultLogLevelsService extends Disposable {
|
|
|
112
112
|
}
|
|
113
113
|
return !isUndefined(result.default) || result.extensions?.length ? result : undefined;
|
|
114
114
|
}
|
|
115
|
-
async migrateLogLevels() {
|
|
116
|
-
const logLevels = await this._readLogLevelsFromArgv();
|
|
117
|
-
const regex = /^([^.]+\..+):(.+)$/;
|
|
118
|
-
if (( logLevels.some(extensionLogLevel => regex.test(extensionLogLevel)))) {
|
|
119
|
-
const argvLogLevel = await this._parseLogLevelsFromArgv();
|
|
120
|
-
if (argvLogLevel) {
|
|
121
|
-
await this._writeLogLevelsToArgv(argvLogLevel);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
115
|
async _readLogLevelsFromArgv() {
|
|
126
116
|
try {
|
|
127
117
|
const content = await this.fileService.readFile(this.environmentService.argvResource);
|
|
@@ -4,21 +4,17 @@ import { localize2, localize } from '@codingame/monaco-vscode-api/vscode/vs/nls'
|
|
|
4
4
|
import { Registry } from '@codingame/monaco-vscode-api/vscode/vs/platform/registry/common/platform';
|
|
5
5
|
import { Categories } from '@codingame/monaco-vscode-api/vscode/vs/platform/action/common/actionCommonCategories';
|
|
6
6
|
import { registerAction2, Action2 } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
7
|
-
import { SetLogLevelAction } from '
|
|
7
|
+
import { SetLogLevelAction } from './logsActions.js';
|
|
8
8
|
import { Extensions as Extensions$1 } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions';
|
|
9
|
-
import {
|
|
10
|
-
import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
|
|
11
|
-
import { Extensions } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/output/common/output';
|
|
9
|
+
import { Extensions, isSingleSourceOutputChannelDescriptor, isMultiSourceOutputChannelDescriptor } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/output/common/output';
|
|
12
10
|
import { IOutputService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/output/common/output.service';
|
|
13
|
-
import { Disposable
|
|
11
|
+
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
14
12
|
import { CONTEXT_LOG_LEVEL, LogLevelToString, isLogLevel } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log';
|
|
15
|
-
import {
|
|
13
|
+
import { ILoggerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
16
14
|
import { LifecyclePhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle';
|
|
17
15
|
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
18
16
|
import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
19
17
|
import { showWindowLogActionId, windowLogId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/log/common/logConstants';
|
|
20
|
-
import { createCancelablePromise, timeout } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
21
|
-
import { isCancellationError, getErrorMessage, CancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
22
18
|
import { IDefaultLogLevelsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/logs/common/defaultLogLevels.service';
|
|
23
19
|
import { ContextKeyExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
|
|
24
20
|
import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
@@ -43,7 +39,7 @@ registerAction2(class extends Action2 {
|
|
|
43
39
|
constructor() {
|
|
44
40
|
super({
|
|
45
41
|
id: 'workbench.action.setDefaultLogLevel',
|
|
46
|
-
title: ( localize2(
|
|
42
|
+
title: ( localize2(7176, "Set Default Log Level")),
|
|
47
43
|
category: Categories.Developer,
|
|
48
44
|
});
|
|
49
45
|
}
|
|
@@ -52,16 +48,13 @@ registerAction2(class extends Action2 {
|
|
|
52
48
|
}
|
|
53
49
|
});
|
|
54
50
|
let LogOutputChannels = class LogOutputChannels extends Disposable {
|
|
55
|
-
constructor(
|
|
51
|
+
constructor(loggerService, contextKeyService, uriIdentityService) {
|
|
56
52
|
super();
|
|
57
|
-
this.logService = logService;
|
|
58
53
|
this.loggerService = loggerService;
|
|
59
54
|
this.contextKeyService = contextKeyService;
|
|
60
|
-
this.fileService = fileService;
|
|
61
55
|
this.uriIdentityService = uriIdentityService;
|
|
62
56
|
this.contextKeys = ( new CounterSet());
|
|
63
57
|
this.outputChannelRegistry = ( Registry.as(Extensions.OutputChannels));
|
|
64
|
-
this.loggerDisposables = this._register(( new DisposableMap()));
|
|
65
58
|
const contextKey = CONTEXT_LOG_LEVEL.bindTo(contextKeyService);
|
|
66
59
|
contextKey.set(LogLevelToString(loggerService.getLogLevel()));
|
|
67
60
|
this._register(loggerService.onDidChangeLogLevel(e => {
|
|
@@ -133,62 +126,55 @@ let LogOutputChannels = class LogOutputChannels extends Disposable {
|
|
|
133
126
|
}
|
|
134
127
|
}
|
|
135
128
|
registerLogChannel(logger) {
|
|
129
|
+
if (logger.group) {
|
|
130
|
+
this.registerCompoundLogChannel(logger.group.id, logger.group.name, logger);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
136
133
|
const channel = this.outputChannelRegistry.getChannel(logger.id);
|
|
137
|
-
if (channel && this.uriIdentityService.extUri.isEqual(channel.
|
|
134
|
+
if (channel && isSingleSourceOutputChannelDescriptor(channel) && this.uriIdentityService.extUri.isEqual(channel.source.resource, logger.resource)) {
|
|
138
135
|
return;
|
|
139
136
|
}
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
catch (error) {
|
|
160
|
-
if (!isCancellationError(error)) {
|
|
161
|
-
this.logService.error('Error while registering log channel', ( logger.resource.toString()), getErrorMessage(error));
|
|
162
|
-
}
|
|
137
|
+
const existingChannel = this.outputChannelRegistry.getChannel(logger.id);
|
|
138
|
+
const remoteLogger = existingChannel && isSingleSourceOutputChannelDescriptor(existingChannel) && existingChannel.source.resource.scheme === Schemas.vscodeRemote ? this.loggerService.getRegisteredLogger(existingChannel.source.resource) : undefined;
|
|
139
|
+
if (remoteLogger) {
|
|
140
|
+
this.deregisterLogChannel(remoteLogger);
|
|
141
|
+
}
|
|
142
|
+
const hasToAppendRemote = existingChannel && logger.resource.scheme === Schemas.vscodeRemote;
|
|
143
|
+
const id = hasToAppendRemote ? `${logger.id}.remote` : logger.id;
|
|
144
|
+
const label = hasToAppendRemote ? ( localize(7177, "{0} (Remote)", logger.name ?? logger.id)) : logger.name ?? logger.id;
|
|
145
|
+
this.outputChannelRegistry.registerChannel({ id, label, source: { resource: logger.resource }, log: true, extensionId: logger.extensionId });
|
|
146
|
+
}
|
|
147
|
+
registerCompoundLogChannel(id, name, logger) {
|
|
148
|
+
const channel = this.outputChannelRegistry.getChannel(id);
|
|
149
|
+
const source = { resource: logger.resource, name: logger.name ?? logger.id };
|
|
150
|
+
if (channel) {
|
|
151
|
+
if (isMultiSourceOutputChannelDescriptor(channel) && !( channel.source.some(
|
|
152
|
+
({ resource }) => this.uriIdentityService.extUri.isEqual(resource, logger.resource)
|
|
153
|
+
))) {
|
|
154
|
+
this.outputChannelRegistry.updateChannelSources(id, [...channel.source, source]);
|
|
163
155
|
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
this.outputChannelRegistry.registerChannel({ id, label: name, log: true, source: [source] });
|
|
159
|
+
}
|
|
167
160
|
}
|
|
168
161
|
deregisterLogChannel(logger) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
if (token.isCancellationRequested) {
|
|
177
|
-
throw ( new CancellationError());
|
|
162
|
+
if (logger.group) {
|
|
163
|
+
const channel = this.outputChannelRegistry.getChannel(logger.group.id);
|
|
164
|
+
if (channel && isMultiSourceOutputChannelDescriptor(channel)) {
|
|
165
|
+
this.outputChannelRegistry.updateChannelSources(logger.group.id, channel.source.filter(({ resource }) => !this.uriIdentityService.extUri.isEqual(resource, logger.resource)));
|
|
166
|
+
}
|
|
178
167
|
}
|
|
179
|
-
|
|
180
|
-
|
|
168
|
+
else {
|
|
169
|
+
this.outputChannelRegistry.removeChannel(logger.id);
|
|
181
170
|
}
|
|
182
|
-
this.logService.debug(`[Registering Log Channel] File does not exist. Waiting for 1s to retry.`, ( file.toString()));
|
|
183
|
-
await timeout(1000, token);
|
|
184
|
-
await this.whenFileExists(file, trial + 1, token);
|
|
185
171
|
}
|
|
186
172
|
registerShowWindowLogAction() {
|
|
187
173
|
this._register(registerAction2(class ShowWindowLogAction extends Action2 {
|
|
188
174
|
constructor() {
|
|
189
175
|
super({
|
|
190
176
|
id: showWindowLogActionId,
|
|
191
|
-
title: ( localize2(
|
|
177
|
+
title: ( localize2(7178, "Show Window Log")),
|
|
192
178
|
category: Categories.Developer,
|
|
193
179
|
f1: true
|
|
194
180
|
});
|
|
@@ -201,19 +187,8 @@ let LogOutputChannels = class LogOutputChannels extends Disposable {
|
|
|
201
187
|
}
|
|
202
188
|
};
|
|
203
189
|
LogOutputChannels = ( __decorate([
|
|
204
|
-
( __param(0,
|
|
205
|
-
( __param(1,
|
|
206
|
-
( __param(2,
|
|
207
|
-
( __param(3, IFileService)),
|
|
208
|
-
( __param(4, IUriIdentityService))
|
|
190
|
+
( __param(0, ILoggerService)),
|
|
191
|
+
( __param(1, IContextKeyService)),
|
|
192
|
+
( __param(2, IUriIdentityService))
|
|
209
193
|
], LogOutputChannels));
|
|
210
|
-
let LogLevelMigration = class LogLevelMigration {
|
|
211
|
-
constructor(defaultLogLevelsService) {
|
|
212
|
-
defaultLogLevelsService.migrateLogLevels();
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
LogLevelMigration = ( __decorate([
|
|
216
|
-
( __param(0, IDefaultLogLevelsService))
|
|
217
|
-
], LogLevelMigration));
|
|
218
194
|
( Registry.as(Extensions$1.Workbench)).registerWorkbenchContribution(LogOutputChannels, LifecyclePhase.Restored);
|
|
219
|
-
( Registry.as(Extensions$1.Workbench)).registerWorkbenchContribution(LogLevelMigration, LifecyclePhase.Eventually);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as nls from "@codingame/monaco-vscode-api/vscode/vs/nls";
|
|
2
|
+
import { Action } from "@codingame/monaco-vscode-api/vscode/vs/base/common/actions";
|
|
3
|
+
import { ILoggerService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
|
|
4
|
+
import { IQuickInputService } from "@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service";
|
|
5
|
+
import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
|
|
6
|
+
import { IWorkbenchEnvironmentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/common/environmentService.service";
|
|
7
|
+
import { IEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service";
|
|
8
|
+
import { IOutputService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/output/common/output.service";
|
|
9
|
+
import { IDefaultLogLevelsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/logs/common/defaultLogLevels.service";
|
|
10
|
+
export declare class SetLogLevelAction extends Action {
|
|
11
|
+
private readonly quickInputService;
|
|
12
|
+
private readonly loggerService;
|
|
13
|
+
private readonly outputService;
|
|
14
|
+
private readonly defaultLogLevelsService;
|
|
15
|
+
static readonly ID = "workbench.action.setLogLevel";
|
|
16
|
+
static readonly TITLE: nls.ILocalizedString;
|
|
17
|
+
constructor(id: string, label: string, quickInputService: IQuickInputService, loggerService: ILoggerService, outputService: IOutputService, defaultLogLevelsService: IDefaultLogLevelsService);
|
|
18
|
+
run(): Promise<void>;
|
|
19
|
+
private selectLogLevelOrChannel;
|
|
20
|
+
private setLogLevelForChannel;
|
|
21
|
+
private getLogLevelEntries;
|
|
22
|
+
private getLabel;
|
|
23
|
+
private getDescription;
|
|
24
|
+
}
|
|
25
|
+
export declare class OpenWindowSessionLogFileAction extends Action {
|
|
26
|
+
private readonly environmentService;
|
|
27
|
+
private readonly fileService;
|
|
28
|
+
private readonly quickInputService;
|
|
29
|
+
private readonly editorService;
|
|
30
|
+
static readonly ID = "workbench.action.openSessionLogFile";
|
|
31
|
+
static readonly TITLE: nls.ILocalizedString;
|
|
32
|
+
constructor(id: string, label: string, environmentService: IWorkbenchEnvironmentService, fileService: IFileService, quickInputService: IQuickInputService, editorService: IEditorService);
|
|
33
|
+
run(): Promise<void>;
|
|
34
|
+
private getSessions;
|
|
35
|
+
private getLogFiles;
|
|
36
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { localize2, localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
4
|
+
import { Action } from '@codingame/monaco-vscode-api/vscode/vs/base/common/actions';
|
|
5
|
+
import { isLogLevel, LogLevel, LogLevelToLocalizedString } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log';
|
|
6
|
+
import { ILoggerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
7
|
+
import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
8
|
+
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
9
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
10
|
+
import { basename, dirname, isEqual } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
11
|
+
import { isSingleSourceOutputChannelDescriptor, isMultiSourceOutputChannelDescriptor } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/output/common/output';
|
|
12
|
+
import { IOutputService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/output/common/output.service';
|
|
13
|
+
import { IDefaultLogLevelsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/logs/common/defaultLogLevels.service';
|
|
14
|
+
import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
|
|
15
|
+
import { ThemeIcon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/themables';
|
|
16
|
+
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
17
|
+
|
|
18
|
+
let SetLogLevelAction = class SetLogLevelAction extends Action {
|
|
19
|
+
static { this.ID = 'workbench.action.setLogLevel'; }
|
|
20
|
+
static { this.TITLE = ( localize2(7179, "Set Log Level...")); }
|
|
21
|
+
constructor(id, label, quickInputService, loggerService, outputService, defaultLogLevelsService) {
|
|
22
|
+
super(id, label);
|
|
23
|
+
this.quickInputService = quickInputService;
|
|
24
|
+
this.loggerService = loggerService;
|
|
25
|
+
this.outputService = outputService;
|
|
26
|
+
this.defaultLogLevelsService = defaultLogLevelsService;
|
|
27
|
+
}
|
|
28
|
+
async run() {
|
|
29
|
+
const logLevelOrChannel = await this.selectLogLevelOrChannel();
|
|
30
|
+
if (logLevelOrChannel !== null) {
|
|
31
|
+
if (isLogLevel(logLevelOrChannel)) {
|
|
32
|
+
this.loggerService.setLogLevel(logLevelOrChannel);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
await this.setLogLevelForChannel(logLevelOrChannel);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async selectLogLevelOrChannel() {
|
|
40
|
+
const defaultLogLevels = await this.defaultLogLevelsService.getDefaultLogLevels();
|
|
41
|
+
const extensionLogs = [], logs = [];
|
|
42
|
+
const logLevel = this.loggerService.getLogLevel();
|
|
43
|
+
for (const channel of this.outputService.getChannelDescriptors()) {
|
|
44
|
+
if (!this.outputService.canSetLogLevel(channel)) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const sources = isSingleSourceOutputChannelDescriptor(channel) ? [channel.source] : isMultiSourceOutputChannelDescriptor(channel) ? channel.source : [];
|
|
48
|
+
if (!sources.length) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const channelLogLevel = sources.reduce((prev, curr) => Math.min(prev, this.loggerService.getLogLevel(curr.resource) ?? logLevel), logLevel);
|
|
52
|
+
const item = {
|
|
53
|
+
id: channel.id,
|
|
54
|
+
label: channel.label,
|
|
55
|
+
description: channelLogLevel !== logLevel ? this.getLabel(channelLogLevel) : undefined,
|
|
56
|
+
channel
|
|
57
|
+
};
|
|
58
|
+
if (channel.extensionId) {
|
|
59
|
+
extensionLogs.push(item);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
logs.push(item);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const entries = [];
|
|
66
|
+
entries.push({ type: 'separator', label: ( localize(7180, "All")) });
|
|
67
|
+
entries.push(...this.getLogLevelEntries(defaultLogLevels.default, this.loggerService.getLogLevel(), true));
|
|
68
|
+
if (extensionLogs.length) {
|
|
69
|
+
entries.push({ type: 'separator', label: ( localize(7181, "Extension Logs")) });
|
|
70
|
+
entries.push(...extensionLogs.sort((a, b) => a.label.localeCompare(b.label)));
|
|
71
|
+
}
|
|
72
|
+
entries.push({ type: 'separator', label: ( localize(7182, "Logs")) });
|
|
73
|
+
entries.push(...logs.sort((a, b) => a.label.localeCompare(b.label)));
|
|
74
|
+
return (new Promise((resolve, reject) => {
|
|
75
|
+
const disposables = ( new DisposableStore());
|
|
76
|
+
const quickPick = disposables.add(this.quickInputService.createQuickPick({ useSeparators: true }));
|
|
77
|
+
quickPick.placeholder = ( localize(7183, "Set Log Level"));
|
|
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.channel.extensionId?.toLowerCase())?.[1] ?? defaultLogLevels.default;
|
|
99
|
+
const entries = this.getLogLevelEntries(defaultLogLevel, this.outputService.getLogLevel(logChannel.channel) ?? defaultLogLevel, !!logChannel.channel.extensionId);
|
|
100
|
+
return (new Promise((resolve, reject) => {
|
|
101
|
+
const disposables = ( new DisposableStore());
|
|
102
|
+
const quickPick = disposables.add(this.quickInputService.createQuickPick());
|
|
103
|
+
quickPick.placeholder = logChannel ? ( localize(7184, " {0}: Select log level", logChannel?.label)) : ( localize(7185, "Select log level"));
|
|
104
|
+
quickPick.items = entries;
|
|
105
|
+
quickPick.activeItems = entries.filter((entry) => entry.level === this.loggerService.getLogLevel());
|
|
106
|
+
let selectedItem;
|
|
107
|
+
disposables.add(quickPick.onDidTriggerItemButton(e => {
|
|
108
|
+
quickPick.hide();
|
|
109
|
+
this.defaultLogLevelsService.setDefaultLogLevel(e.item.level, logChannel.channel.extensionId);
|
|
110
|
+
}));
|
|
111
|
+
disposables.add(quickPick.onDidAccept(e => {
|
|
112
|
+
selectedItem = quickPick.selectedItems[0];
|
|
113
|
+
quickPick.hide();
|
|
114
|
+
}));
|
|
115
|
+
disposables.add(quickPick.onDidHide(() => {
|
|
116
|
+
if (selectedItem) {
|
|
117
|
+
this.outputService.setLogLevel(logChannel.channel, selectedItem.level);
|
|
118
|
+
}
|
|
119
|
+
disposables.dispose();
|
|
120
|
+
resolve();
|
|
121
|
+
}));
|
|
122
|
+
quickPick.show();
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
getLogLevelEntries(defaultLogLevel, currentLogLevel, canSetDefaultLogLevel) {
|
|
126
|
+
const button = canSetDefaultLogLevel ? { iconClass: ThemeIcon.asClassName(Codicon.checkAll), tooltip: ( localize(7186, "Set as Default Log Level")) } : undefined;
|
|
127
|
+
return [
|
|
128
|
+
{ label: this.getLabel(LogLevel.Trace, currentLogLevel), level: LogLevel.Trace, description: this.getDescription(LogLevel.Trace, defaultLogLevel), buttons: button && defaultLogLevel !== LogLevel.Trace ? [button] : undefined },
|
|
129
|
+
{ label: this.getLabel(LogLevel.Debug, currentLogLevel), level: LogLevel.Debug, description: this.getDescription(LogLevel.Debug, defaultLogLevel), buttons: button && defaultLogLevel !== LogLevel.Debug ? [button] : undefined },
|
|
130
|
+
{ label: this.getLabel(LogLevel.Info, currentLogLevel), level: LogLevel.Info, description: this.getDescription(LogLevel.Info, defaultLogLevel), buttons: button && defaultLogLevel !== LogLevel.Info ? [button] : undefined },
|
|
131
|
+
{ label: this.getLabel(LogLevel.Warning, currentLogLevel), level: LogLevel.Warning, description: this.getDescription(LogLevel.Warning, defaultLogLevel), buttons: button && defaultLogLevel !== LogLevel.Warning ? [button] : undefined },
|
|
132
|
+
{ label: this.getLabel(LogLevel.Error, currentLogLevel), level: LogLevel.Error, description: this.getDescription(LogLevel.Error, defaultLogLevel), buttons: button && defaultLogLevel !== LogLevel.Error ? [button] : undefined },
|
|
133
|
+
{ label: this.getLabel(LogLevel.Off, currentLogLevel), level: LogLevel.Off, description: this.getDescription(LogLevel.Off, defaultLogLevel), buttons: button && defaultLogLevel !== LogLevel.Off ? [button] : undefined },
|
|
134
|
+
];
|
|
135
|
+
}
|
|
136
|
+
getLabel(level, current) {
|
|
137
|
+
const label = LogLevelToLocalizedString(level).value;
|
|
138
|
+
return level === current ? `$(check) ${label}` : label;
|
|
139
|
+
}
|
|
140
|
+
getDescription(level, defaultLogLevel) {
|
|
141
|
+
return defaultLogLevel === level ? ( localize(7187, "Default")) : undefined;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
SetLogLevelAction = ( __decorate([
|
|
145
|
+
( __param(2, IQuickInputService)),
|
|
146
|
+
( __param(3, ILoggerService)),
|
|
147
|
+
( __param(4, IOutputService)),
|
|
148
|
+
( __param(5, IDefaultLogLevelsService))
|
|
149
|
+
], SetLogLevelAction));
|
|
150
|
+
(class OpenWindowSessionLogFileAction extends Action {
|
|
151
|
+
static { this.ID = 'workbench.action.openSessionLogFile'; }
|
|
152
|
+
static { this.TITLE = ( localize2(7188, "Open Window Log File (Session)...")); }
|
|
153
|
+
constructor(id, label, environmentService, fileService, quickInputService, editorService) {
|
|
154
|
+
super(id, label);
|
|
155
|
+
this.environmentService = environmentService;
|
|
156
|
+
this.fileService = fileService;
|
|
157
|
+
this.quickInputService = quickInputService;
|
|
158
|
+
this.editorService = editorService;
|
|
159
|
+
}
|
|
160
|
+
async run() {
|
|
161
|
+
const sessionResult = await this.quickInputService.pick(this.getSessions().then(sessions => ( sessions.map((s, index) => ({
|
|
162
|
+
id: ( s.toString()),
|
|
163
|
+
label: basename(s),
|
|
164
|
+
description: index === 0 ? ( localize(7189, "Current")) : undefined
|
|
165
|
+
})))), {
|
|
166
|
+
canPickMany: false,
|
|
167
|
+
placeHolder: ( localize(7190, "Select Session"))
|
|
168
|
+
});
|
|
169
|
+
if (sessionResult) {
|
|
170
|
+
const logFileResult = await this.quickInputService.pick(this.getLogFiles(( URI.parse(sessionResult.id))).then(logFiles => ( logFiles.map((s) => ({
|
|
171
|
+
id: ( s.toString()),
|
|
172
|
+
label: basename(s)
|
|
173
|
+
})))), {
|
|
174
|
+
canPickMany: false,
|
|
175
|
+
placeHolder: ( localize(7191, "Select Log file"))
|
|
176
|
+
});
|
|
177
|
+
if (logFileResult) {
|
|
178
|
+
return this.editorService.openEditor({ resource: ( URI.parse(logFileResult.id)), options: { pinned: true } }).then(() => undefined);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
async getSessions() {
|
|
183
|
+
const logsPath = this.environmentService.logsHome.with({ scheme: this.environmentService.logFile.scheme });
|
|
184
|
+
const result = [logsPath];
|
|
185
|
+
const stat = await this.fileService.resolve(dirname(logsPath));
|
|
186
|
+
if (stat.children) {
|
|
187
|
+
result.push(...( stat.children
|
|
188
|
+
.filter(stat => !isEqual(stat.resource, logsPath) && stat.isDirectory && /^\d{8}T\d{6}$/.test(stat.name))
|
|
189
|
+
.sort()
|
|
190
|
+
.reverse()
|
|
191
|
+
.map(d => d.resource)));
|
|
192
|
+
}
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
async getLogFiles(session) {
|
|
196
|
+
const stat = await this.fileService.resolve(session);
|
|
197
|
+
if (stat.children) {
|
|
198
|
+
return ( stat.children.filter(stat => !stat.isDirectory).map(stat => stat.resource));
|
|
199
|
+
}
|
|
200
|
+
return [];
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
export { SetLogLevelAction };
|