@codingame/monaco-vscode-log-service-override 4.4.0 → 4.5.0-improve-code-splitting.1
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/log.js +7 -5
- package/package.json +11 -3
- package/vscode/src/vs/platform/log/common/fileLog.js +2 -1
- package/vscode/src/vs/workbench/contrib/logs/common/defaultLogLevels.js +158 -0
- package/vscode/src/vs/workbench/contrib/logs/common/logs.contribution.js +15 -11
- package/vscode/src/vs/workbench/contrib/logs/common/logsActions.js +237 -0
package/log.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
2
|
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
3
|
-
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
|
|
4
|
-
import {
|
|
3
|
+
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
4
|
+
import { getLogLevel } from 'vscode/vscode/vs/platform/log/common/log';
|
|
5
5
|
export { ConsoleLogger } from 'vscode/vscode/vs/platform/log/common/log';
|
|
6
|
+
import { ILoggerService, ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
6
7
|
import { FileLoggerService } from './vscode/src/vs/platform/log/common/fileLog.js';
|
|
7
8
|
import { LogService } from 'vscode/vscode/vs/platform/log/common/logService';
|
|
8
|
-
import { IEnvironmentService } from 'vscode/vscode/vs/platform/environment/common/environment';
|
|
9
|
+
import { IEnvironmentService } from 'vscode/vscode/vs/platform/environment/common/environment.service';
|
|
9
10
|
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
10
11
|
import { windowLogId } from 'vscode/vscode/vs/workbench/services/log/common/logConstants';
|
|
11
|
-
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService';
|
|
12
|
+
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
12
13
|
import { toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
13
|
-
import {
|
|
14
|
+
import { DefaultLogLevelsService } from './vscode/src/vs/workbench/contrib/logs/common/defaultLogLevels.js';
|
|
15
|
+
import { IDefaultLogLevelsService } from 'vscode/vscode/vs/workbench/contrib/logs/common/defaultLogLevels.service';
|
|
14
16
|
import getServiceOverride$1 from '@codingame/monaco-vscode-environment-service-override';
|
|
15
17
|
import { logsPath } from 'vscode/workbench';
|
|
16
18
|
import { checkServicesNotInitialized } from 'vscode/lifecycle';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-log-service-override",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0-improve-code-splitting.1",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -17,8 +17,16 @@
|
|
|
17
17
|
"main": "index.js",
|
|
18
18
|
"module": "index.js",
|
|
19
19
|
"types": "index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"default": "./index.js"
|
|
23
|
+
},
|
|
24
|
+
"./vscode/*": {
|
|
25
|
+
"default": "./vscode/src/*.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
20
28
|
"dependencies": {
|
|
21
|
-
"vscode": "npm:@codingame/monaco-vscode-api@4.
|
|
22
|
-
"@codingame/monaco-vscode-environment-service-override": "4.
|
|
29
|
+
"vscode": "npm:@codingame/monaco-vscode-api@4.5.0-improve-code-splitting.1",
|
|
30
|
+
"@codingame/monaco-vscode-environment-service-override": "4.5.0-improve-code-splitting.1"
|
|
23
31
|
}
|
|
24
32
|
}
|
|
@@ -2,7 +2,8 @@ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
|
2
2
|
import { ThrottledDelayer } from 'vscode/vscode/vs/base/common/async';
|
|
3
3
|
import { VSBuffer } from 'vscode/vscode/vs/base/common/buffer';
|
|
4
4
|
import { joinPath, dirname, basename } from 'vscode/vscode/vs/base/common/resources';
|
|
5
|
-
import { ByteSize,
|
|
5
|
+
import { ByteSize, whenProviderRegistered } from 'vscode/vscode/vs/platform/files/common/files';
|
|
6
|
+
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
6
7
|
import { BufferLogger } from 'vscode/vscode/vs/platform/log/common/bufferLog';
|
|
7
8
|
import { AbstractMessageLogger, LogLevel, AbstractLoggerService } from 'vscode/vscode/vs/platform/log/common/log';
|
|
8
9
|
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import { getLogLevel, LogLevelToString, parseLogLevel } from 'vscode/vscode/vs/platform/log/common/log';
|
|
3
|
+
import { ILogService, ILoggerService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
4
|
+
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
5
|
+
import { toFileOperationResult } from 'vscode/vscode/vs/platform/files/common/files';
|
|
6
|
+
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
7
|
+
import { IJSONEditingService } from 'vscode/vscode/vs/workbench/services/configuration/common/jsonEditing.service';
|
|
8
|
+
import { isUndefined, isString } from 'vscode/vscode/vs/base/common/types';
|
|
9
|
+
import { EXTENSION_IDENTIFIER_WITH_LOG_REGEX } from '@codingame/monaco-vscode-environment-service-override/vscode/vs/platform/environment/common/environmentService';
|
|
10
|
+
import { parse } from 'vscode/vscode/vs/base/common/json';
|
|
11
|
+
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
12
|
+
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
13
|
+
import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
14
|
+
|
|
15
|
+
let DefaultLogLevelsService = class DefaultLogLevelsService extends Disposable {
|
|
16
|
+
constructor(environmentService, fileService, jsonEditingService, logService, loggerService) {
|
|
17
|
+
super();
|
|
18
|
+
this.environmentService = environmentService;
|
|
19
|
+
this.fileService = fileService;
|
|
20
|
+
this.jsonEditingService = jsonEditingService;
|
|
21
|
+
this.logService = logService;
|
|
22
|
+
this.loggerService = loggerService;
|
|
23
|
+
this._onDidChangeDefaultLogLevels = this._register(( new Emitter()));
|
|
24
|
+
this.onDidChangeDefaultLogLevels = this._onDidChangeDefaultLogLevels.event;
|
|
25
|
+
}
|
|
26
|
+
async getDefaultLogLevels() {
|
|
27
|
+
const argvLogLevel = await this._parseLogLevelsFromArgv();
|
|
28
|
+
return {
|
|
29
|
+
default: argvLogLevel?.default ?? this._getDefaultLogLevelFromEnv(),
|
|
30
|
+
extensions: argvLogLevel?.extensions ?? this._getExtensionsDefaultLogLevelsFromEnv()
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
async getDefaultLogLevel(extensionId) {
|
|
34
|
+
const argvLogLevel = (await this._parseLogLevelsFromArgv()) ?? {};
|
|
35
|
+
if (extensionId) {
|
|
36
|
+
extensionId = extensionId.toLowerCase();
|
|
37
|
+
return this._getDefaultLogLevel(argvLogLevel, extensionId);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return this._getDefaultLogLevel(argvLogLevel);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async setDefaultLogLevel(defaultLogLevel, extensionId) {
|
|
44
|
+
const argvLogLevel = (await this._parseLogLevelsFromArgv()) ?? {};
|
|
45
|
+
if (extensionId) {
|
|
46
|
+
extensionId = extensionId.toLowerCase();
|
|
47
|
+
const currentDefaultLogLevel = this._getDefaultLogLevel(argvLogLevel, extensionId);
|
|
48
|
+
argvLogLevel.extensions = argvLogLevel.extensions ?? [];
|
|
49
|
+
const extension = argvLogLevel.extensions.find(([extension]) => extension === extensionId);
|
|
50
|
+
if (extension) {
|
|
51
|
+
extension[1] = defaultLogLevel;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
argvLogLevel.extensions.push([extensionId, defaultLogLevel]);
|
|
55
|
+
}
|
|
56
|
+
await this._writeLogLevelsToArgv(argvLogLevel);
|
|
57
|
+
const extensionLoggers = [...this.loggerService.getRegisteredLoggers()].filter(logger => logger.extensionId && logger.extensionId.toLowerCase() === extensionId);
|
|
58
|
+
for (const { resource } of extensionLoggers) {
|
|
59
|
+
if (this.loggerService.getLogLevel(resource) === currentDefaultLogLevel) {
|
|
60
|
+
this.loggerService.setLogLevel(resource, defaultLogLevel);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
const currentLogLevel = this._getDefaultLogLevel(argvLogLevel);
|
|
66
|
+
argvLogLevel.default = defaultLogLevel;
|
|
67
|
+
await this._writeLogLevelsToArgv(argvLogLevel);
|
|
68
|
+
if (this.loggerService.getLogLevel() === currentLogLevel) {
|
|
69
|
+
this.loggerService.setLogLevel(defaultLogLevel);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
this._onDidChangeDefaultLogLevels.fire();
|
|
73
|
+
}
|
|
74
|
+
_getDefaultLogLevel(argvLogLevels, extension) {
|
|
75
|
+
if (extension) {
|
|
76
|
+
const extensionLogLevel = argvLogLevels.extensions?.find(([extensionId]) => extensionId === extension);
|
|
77
|
+
if (extensionLogLevel) {
|
|
78
|
+
return extensionLogLevel[1];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return argvLogLevels.default ?? getLogLevel(this.environmentService);
|
|
82
|
+
}
|
|
83
|
+
async _writeLogLevelsToArgv(logLevels) {
|
|
84
|
+
const logLevelsValue = [];
|
|
85
|
+
if (!isUndefined(logLevels.default)) {
|
|
86
|
+
logLevelsValue.push(LogLevelToString(logLevels.default));
|
|
87
|
+
}
|
|
88
|
+
for (const [extension, logLevel] of logLevels.extensions ?? []) {
|
|
89
|
+
logLevelsValue.push(`${extension}=${LogLevelToString(logLevel)}`);
|
|
90
|
+
}
|
|
91
|
+
await this.jsonEditingService.write(this.environmentService.argvResource, [{ path: ['log-level'], value: logLevelsValue.length ? logLevelsValue : undefined }], true);
|
|
92
|
+
}
|
|
93
|
+
async _parseLogLevelsFromArgv() {
|
|
94
|
+
const result = { extensions: [] };
|
|
95
|
+
const logLevels = await this._readLogLevelsFromArgv();
|
|
96
|
+
for (const extensionLogLevel of logLevels) {
|
|
97
|
+
const matches = EXTENSION_IDENTIFIER_WITH_LOG_REGEX.exec(extensionLogLevel);
|
|
98
|
+
if (matches && matches[1] && matches[2]) {
|
|
99
|
+
const logLevel = parseLogLevel(matches[2]);
|
|
100
|
+
if (!isUndefined(logLevel)) {
|
|
101
|
+
result.extensions?.push([matches[1].toLowerCase(), logLevel]);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
const logLevel = parseLogLevel(extensionLogLevel);
|
|
106
|
+
if (!isUndefined(logLevel)) {
|
|
107
|
+
result.default = logLevel;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return !isUndefined(result.default) || result.extensions?.length ? result : undefined;
|
|
112
|
+
}
|
|
113
|
+
async migrateLogLevels() {
|
|
114
|
+
const logLevels = await this._readLogLevelsFromArgv();
|
|
115
|
+
const regex = /^([^.]+\..+):(.+)$/;
|
|
116
|
+
if (( logLevels.some(extensionLogLevel => regex.test(extensionLogLevel)))) {
|
|
117
|
+
const argvLogLevel = await this._parseLogLevelsFromArgv();
|
|
118
|
+
if (argvLogLevel) {
|
|
119
|
+
await this._writeLogLevelsToArgv(argvLogLevel);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async _readLogLevelsFromArgv() {
|
|
124
|
+
try {
|
|
125
|
+
const content = await this.fileService.readFile(this.environmentService.argvResource);
|
|
126
|
+
const argv = parse(( content.value.toString()));
|
|
127
|
+
return isString(argv['log-level']) ? [argv['log-level']] : Array.isArray(argv['log-level']) ? argv['log-level'] : [];
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
if (toFileOperationResult(error) !== 1 ) {
|
|
131
|
+
this.logService.error(error);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return [];
|
|
135
|
+
}
|
|
136
|
+
_getDefaultLogLevelFromEnv() {
|
|
137
|
+
return getLogLevel(this.environmentService);
|
|
138
|
+
}
|
|
139
|
+
_getExtensionsDefaultLogLevelsFromEnv() {
|
|
140
|
+
const result = [];
|
|
141
|
+
for (const [extension, logLevelValue] of this.environmentService.extensionLogLevel ?? []) {
|
|
142
|
+
const logLevel = parseLogLevel(logLevelValue);
|
|
143
|
+
if (!isUndefined(logLevel)) {
|
|
144
|
+
result.push([extension, logLevel]);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
DefaultLogLevelsService = ( __decorate([
|
|
151
|
+
( __param(0, IWorkbenchEnvironmentService)),
|
|
152
|
+
( __param(1, IFileService)),
|
|
153
|
+
( __param(2, IJSONEditingService)),
|
|
154
|
+
( __param(3, ILogService)),
|
|
155
|
+
( __param(4, ILoggerService))
|
|
156
|
+
], DefaultLogLevelsService));
|
|
157
|
+
|
|
158
|
+
export { DefaultLogLevelsService };
|
|
@@ -3,21 +3,25 @@ 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 '
|
|
7
|
-
import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { SetLogLevelAction } from './logsActions.js';
|
|
7
|
+
import { Extensions as Extensions$1 } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
8
|
+
import { whenProviderRegistered } from 'vscode/vscode/vs/platform/files/common/files';
|
|
9
|
+
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
10
|
+
import { Extensions } from 'vscode/vscode/vs/workbench/services/output/common/output';
|
|
11
|
+
import { IOutputService } from 'vscode/vscode/vs/workbench/services/output/common/output.service';
|
|
10
12
|
import { Disposable, DisposableMap, DisposableStore, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
11
|
-
import {
|
|
13
|
+
import { CONTEXT_LOG_LEVEL, LogLevelToString, isLogLevel } from 'vscode/vscode/vs/platform/log/common/log';
|
|
14
|
+
import { ILogService, ILoggerService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
12
15
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
13
16
|
import { Event } from 'vscode/vscode/vs/base/common/event';
|
|
14
17
|
import { showWindowLogActionId, windowLogId } from 'vscode/vscode/vs/workbench/services/log/common/logConstants';
|
|
15
18
|
import { createCancelablePromise, timeout } from 'vscode/vscode/vs/base/common/async';
|
|
16
19
|
import { isCancellationError, getErrorMessage, CancellationError } from 'vscode/vscode/vs/base/common/errors';
|
|
17
|
-
import { IDefaultLogLevelsService } from 'vscode/vscode/vs/workbench/contrib/logs/common/defaultLogLevels';
|
|
18
|
-
import {
|
|
20
|
+
import { IDefaultLogLevelsService } from 'vscode/vscode/vs/workbench/contrib/logs/common/defaultLogLevels.service';
|
|
21
|
+
import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
22
|
+
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
19
23
|
import { CounterSet } from 'vscode/vscode/vs/base/common/map';
|
|
20
|
-
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
|
|
24
|
+
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
|
|
21
25
|
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
22
26
|
|
|
23
27
|
registerAction2(class extends Action2 {
|
|
@@ -58,7 +62,7 @@ let LogOutputChannels = class LogOutputChannels extends Disposable {
|
|
|
58
62
|
this.fileService = fileService;
|
|
59
63
|
this.uriIdentityService = uriIdentityService;
|
|
60
64
|
this.contextKeys = ( new CounterSet());
|
|
61
|
-
this.outputChannelRegistry = ( Registry.as(Extensions
|
|
65
|
+
this.outputChannelRegistry = ( Registry.as(Extensions.OutputChannels));
|
|
62
66
|
this.loggerDisposables = this._register(( new DisposableMap()));
|
|
63
67
|
const contextKey = CONTEXT_LOG_LEVEL.bindTo(contextKeyService);
|
|
64
68
|
contextKey.set(LogLevelToString(loggerService.getLogLevel()));
|
|
@@ -222,5 +226,5 @@ let LogLevelMigration = class LogLevelMigration {
|
|
|
222
226
|
LogLevelMigration = ( __decorate([
|
|
223
227
|
( __param(0, IDefaultLogLevelsService))
|
|
224
228
|
], LogLevelMigration));
|
|
225
|
-
( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(LogOutputChannels, 3 );
|
|
226
|
-
( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(LogLevelMigration, 4 );
|
|
229
|
+
( Registry.as(Extensions$1.Workbench)).registerWorkbenchContribution(LogOutputChannels, 3 );
|
|
230
|
+
( Registry.as(Extensions$1.Workbench)).registerWorkbenchContribution(LogLevelMigration, 4 );
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/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, LogLevelToLocalizedString } from 'vscode/vscode/vs/platform/log/common/log';
|
|
5
|
+
import { ILoggerService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
6
|
+
import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
7
|
+
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
8
|
+
import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
9
|
+
import { basename, dirname, isEqual } from 'vscode/vscode/vs/base/common/resources';
|
|
10
|
+
import { IOutputService } from 'vscode/vscode/vs/workbench/services/output/common/output.service';
|
|
11
|
+
import { telemetryLogId, extensionTelemetryLogChannelId } from 'vscode/vscode/vs/platform/telemetry/common/telemetryUtils';
|
|
12
|
+
import { IDefaultLogLevelsService } from 'vscode/vscode/vs/workbench/contrib/logs/common/defaultLogLevels.service';
|
|
13
|
+
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
14
|
+
import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
|
|
15
|
+
import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
16
|
+
|
|
17
|
+
var SetLogLevelAction_1;
|
|
18
|
+
let SetLogLevelAction = class SetLogLevelAction extends Action {
|
|
19
|
+
static { SetLogLevelAction_1 = this; }
|
|
20
|
+
static { this.ID = 'workbench.action.setLogLevel'; }
|
|
21
|
+
static { this.TITLE = ( localize2WithPath(
|
|
22
|
+
'vs/workbench/contrib/logs/common/logsActions',
|
|
23
|
+
'setLogLevel',
|
|
24
|
+
"Set Log Level..."
|
|
25
|
+
)); }
|
|
26
|
+
constructor(id, label, quickInputService, loggerService, outputService, defaultLogLevelsService) {
|
|
27
|
+
super(id, label);
|
|
28
|
+
this.quickInputService = quickInputService;
|
|
29
|
+
this.loggerService = loggerService;
|
|
30
|
+
this.outputService = outputService;
|
|
31
|
+
this.defaultLogLevelsService = defaultLogLevelsService;
|
|
32
|
+
}
|
|
33
|
+
async run() {
|
|
34
|
+
const logLevelOrChannel = await this.selectLogLevelOrChannel();
|
|
35
|
+
if (logLevelOrChannel !== null) {
|
|
36
|
+
if (isLogLevel(logLevelOrChannel)) {
|
|
37
|
+
this.loggerService.setLogLevel(logLevelOrChannel);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
await this.setLogLevelForChannel(logLevelOrChannel);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async selectLogLevelOrChannel() {
|
|
45
|
+
const defaultLogLevels = await this.defaultLogLevelsService.getDefaultLogLevels();
|
|
46
|
+
const extensionLogs = [], logs = [];
|
|
47
|
+
const logLevel = this.loggerService.getLogLevel();
|
|
48
|
+
for (const channel of this.outputService.getChannelDescriptors()) {
|
|
49
|
+
if (!SetLogLevelAction_1.isLevelSettable(channel) || !channel.file) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const channelLogLevel = this.loggerService.getLogLevel(channel.file) ?? logLevel;
|
|
53
|
+
const item = { id: channel.id, resource: channel.file, label: channel.label, description: channelLogLevel !== logLevel ? this.getLabel(channelLogLevel) : undefined, extensionId: channel.extensionId };
|
|
54
|
+
if (channel.extensionId) {
|
|
55
|
+
extensionLogs.push(item);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
logs.push(item);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const entries = [];
|
|
62
|
+
entries.push({ type: 'separator', label: ( localizeWithPath('vs/workbench/contrib/logs/common/logsActions', 'all', "All")) });
|
|
63
|
+
entries.push(...this.getLogLevelEntries(defaultLogLevels.default, this.loggerService.getLogLevel(), true));
|
|
64
|
+
if (extensionLogs.length) {
|
|
65
|
+
entries.push({ type: 'separator', label: ( localizeWithPath(
|
|
66
|
+
'vs/workbench/contrib/logs/common/logsActions',
|
|
67
|
+
'extensionLogs',
|
|
68
|
+
"Extension Logs"
|
|
69
|
+
)) });
|
|
70
|
+
entries.push(...extensionLogs.sort((a, b) => a.label.localeCompare(b.label)));
|
|
71
|
+
}
|
|
72
|
+
entries.push({ type: 'separator', label: ( localizeWithPath('vs/workbench/contrib/logs/common/logsActions', 'loggers', "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 = this.quickInputService.createQuickPick();
|
|
77
|
+
quickPick.placeholder = ( localizeWithPath(
|
|
78
|
+
'vs/workbench/contrib/logs/common/logsActions',
|
|
79
|
+
'selectlog',
|
|
80
|
+
"Set Log Level"
|
|
81
|
+
));
|
|
82
|
+
quickPick.items = entries;
|
|
83
|
+
let selectedItem;
|
|
84
|
+
disposables.add(quickPick.onDidTriggerItemButton(e => {
|
|
85
|
+
quickPick.hide();
|
|
86
|
+
this.defaultLogLevelsService.setDefaultLogLevel(e.item.level);
|
|
87
|
+
}));
|
|
88
|
+
disposables.add(quickPick.onDidAccept(e => {
|
|
89
|
+
selectedItem = quickPick.selectedItems[0];
|
|
90
|
+
quickPick.hide();
|
|
91
|
+
}));
|
|
92
|
+
disposables.add(quickPick.onDidHide(() => {
|
|
93
|
+
const result = selectedItem ? selectedItem.level ?? selectedItem : null;
|
|
94
|
+
disposables.dispose();
|
|
95
|
+
resolve(result);
|
|
96
|
+
}));
|
|
97
|
+
quickPick.show();
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
static isLevelSettable(channel) {
|
|
101
|
+
return channel.log && channel.file !== undefined && channel.id !== telemetryLogId && channel.id !== extensionTelemetryLogChannelId;
|
|
102
|
+
}
|
|
103
|
+
async setLogLevelForChannel(logChannel) {
|
|
104
|
+
const defaultLogLevels = await this.defaultLogLevelsService.getDefaultLogLevels();
|
|
105
|
+
const defaultLogLevel = defaultLogLevels.extensions.find(e => e[0] === logChannel.extensionId?.toLowerCase())?.[1] ?? defaultLogLevels.default;
|
|
106
|
+
const currentLogLevel = this.loggerService.getLogLevel(logChannel.resource) ?? defaultLogLevel;
|
|
107
|
+
const entries = this.getLogLevelEntries(defaultLogLevel, currentLogLevel, !!logChannel.extensionId);
|
|
108
|
+
return ( new Promise((resolve, reject) => {
|
|
109
|
+
const disposables = ( new DisposableStore());
|
|
110
|
+
const quickPick = this.quickInputService.createQuickPick();
|
|
111
|
+
quickPick.placeholder = logChannel ? ( localizeWithPath(
|
|
112
|
+
'vs/workbench/contrib/logs/common/logsActions',
|
|
113
|
+
'selectLogLevelFor',
|
|
114
|
+
" {0}: Select log level",
|
|
115
|
+
logChannel?.label
|
|
116
|
+
)) : ( localizeWithPath(
|
|
117
|
+
'vs/workbench/contrib/logs/common/logsActions',
|
|
118
|
+
'selectLogLevel',
|
|
119
|
+
"Select log level"
|
|
120
|
+
));
|
|
121
|
+
quickPick.items = entries;
|
|
122
|
+
quickPick.activeItems = entries.filter((entry) => entry.level === this.loggerService.getLogLevel());
|
|
123
|
+
let selectedItem;
|
|
124
|
+
disposables.add(quickPick.onDidTriggerItemButton(e => {
|
|
125
|
+
quickPick.hide();
|
|
126
|
+
this.defaultLogLevelsService.setDefaultLogLevel(e.item.level, logChannel.extensionId);
|
|
127
|
+
}));
|
|
128
|
+
disposables.add(quickPick.onDidAccept(e => {
|
|
129
|
+
selectedItem = quickPick.selectedItems[0];
|
|
130
|
+
quickPick.hide();
|
|
131
|
+
}));
|
|
132
|
+
disposables.add(quickPick.onDidHide(() => {
|
|
133
|
+
if (selectedItem) {
|
|
134
|
+
this.loggerService.setLogLevel(logChannel.resource, selectedItem.level);
|
|
135
|
+
}
|
|
136
|
+
disposables.dispose();
|
|
137
|
+
resolve();
|
|
138
|
+
}));
|
|
139
|
+
quickPick.show();
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
getLogLevelEntries(defaultLogLevel, currentLogLevel, canSetDefaultLogLevel) {
|
|
143
|
+
const button = canSetDefaultLogLevel ? { iconClass: ThemeIcon.asClassName(Codicon.checkAll), tooltip: ( localizeWithPath(
|
|
144
|
+
'vs/workbench/contrib/logs/common/logsActions',
|
|
145
|
+
'resetLogLevel',
|
|
146
|
+
"Set as Default Log Level"
|
|
147
|
+
)) } : undefined;
|
|
148
|
+
return [
|
|
149
|
+
{ label: this.getLabel(LogLevel.Trace, currentLogLevel), level: LogLevel.Trace, description: this.getDescription(LogLevel.Trace, defaultLogLevel), buttons: button && defaultLogLevel !== LogLevel.Trace ? [button] : undefined },
|
|
150
|
+
{ label: this.getLabel(LogLevel.Debug, currentLogLevel), level: LogLevel.Debug, description: this.getDescription(LogLevel.Debug, defaultLogLevel), buttons: button && defaultLogLevel !== LogLevel.Debug ? [button] : undefined },
|
|
151
|
+
{ label: this.getLabel(LogLevel.Info, currentLogLevel), level: LogLevel.Info, description: this.getDescription(LogLevel.Info, defaultLogLevel), buttons: button && defaultLogLevel !== LogLevel.Info ? [button] : undefined },
|
|
152
|
+
{ label: this.getLabel(LogLevel.Warning, currentLogLevel), level: LogLevel.Warning, description: this.getDescription(LogLevel.Warning, defaultLogLevel), buttons: button && defaultLogLevel !== LogLevel.Warning ? [button] : undefined },
|
|
153
|
+
{ label: this.getLabel(LogLevel.Error, currentLogLevel), level: LogLevel.Error, description: this.getDescription(LogLevel.Error, defaultLogLevel), buttons: button && defaultLogLevel !== LogLevel.Error ? [button] : undefined },
|
|
154
|
+
{ label: this.getLabel(LogLevel.Off, currentLogLevel), level: LogLevel.Off, description: this.getDescription(LogLevel.Off, defaultLogLevel), buttons: button && defaultLogLevel !== LogLevel.Off ? [button] : undefined },
|
|
155
|
+
];
|
|
156
|
+
}
|
|
157
|
+
getLabel(level, current) {
|
|
158
|
+
const label = LogLevelToLocalizedString(level).value;
|
|
159
|
+
return level === current ? `$(check) ${label}` : label;
|
|
160
|
+
}
|
|
161
|
+
getDescription(level, defaultLogLevel) {
|
|
162
|
+
return defaultLogLevel === level ? ( localizeWithPath('vs/workbench/contrib/logs/common/logsActions', 'default', "Default")) : undefined;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
SetLogLevelAction = SetLogLevelAction_1 = ( __decorate([
|
|
166
|
+
( __param(2, IQuickInputService)),
|
|
167
|
+
( __param(3, ILoggerService)),
|
|
168
|
+
( __param(4, IOutputService)),
|
|
169
|
+
( __param(5, IDefaultLogLevelsService))
|
|
170
|
+
], SetLogLevelAction));
|
|
171
|
+
(class OpenWindowSessionLogFileAction extends Action {
|
|
172
|
+
static { this.ID = 'workbench.action.openSessionLogFile'; }
|
|
173
|
+
static { this.TITLE = ( localize2WithPath(
|
|
174
|
+
'vs/workbench/contrib/logs/common/logsActions',
|
|
175
|
+
'openSessionLogFile',
|
|
176
|
+
"Open Window Log File (Session)..."
|
|
177
|
+
)); }
|
|
178
|
+
constructor(id, label, environmentService, fileService, quickInputService, editorService) {
|
|
179
|
+
super(id, label);
|
|
180
|
+
this.environmentService = environmentService;
|
|
181
|
+
this.fileService = fileService;
|
|
182
|
+
this.quickInputService = quickInputService;
|
|
183
|
+
this.editorService = editorService;
|
|
184
|
+
}
|
|
185
|
+
async run() {
|
|
186
|
+
const sessionResult = await this.quickInputService.pick(this.getSessions().then(sessions => ( sessions.map((s, index) => ({
|
|
187
|
+
id: ( s.toString()),
|
|
188
|
+
label: basename(s),
|
|
189
|
+
description: index === 0 ? ( localizeWithPath('vs/workbench/contrib/logs/common/logsActions', 'current', "Current")) : undefined
|
|
190
|
+
})))), {
|
|
191
|
+
canPickMany: false,
|
|
192
|
+
placeHolder: ( localizeWithPath(
|
|
193
|
+
'vs/workbench/contrib/logs/common/logsActions',
|
|
194
|
+
'sessions placeholder',
|
|
195
|
+
"Select Session"
|
|
196
|
+
))
|
|
197
|
+
});
|
|
198
|
+
if (sessionResult) {
|
|
199
|
+
const logFileResult = await this.quickInputService.pick(this.getLogFiles(( URI.parse(sessionResult.id))).then(logFiles => ( logFiles.map(s => ({
|
|
200
|
+
id: ( s.toString()),
|
|
201
|
+
label: basename(s)
|
|
202
|
+
})))), {
|
|
203
|
+
canPickMany: false,
|
|
204
|
+
placeHolder: ( localizeWithPath(
|
|
205
|
+
'vs/workbench/contrib/logs/common/logsActions',
|
|
206
|
+
'log placeholder',
|
|
207
|
+
"Select Log file"
|
|
208
|
+
))
|
|
209
|
+
});
|
|
210
|
+
if (logFileResult) {
|
|
211
|
+
return this.editorService.openEditor({ resource: ( URI.parse(logFileResult.id)), options: { pinned: true } }).then(() => undefined);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
async getSessions() {
|
|
216
|
+
const logsPath = this.environmentService.logsHome.with({ scheme: this.environmentService.logFile.scheme });
|
|
217
|
+
const result = [logsPath];
|
|
218
|
+
const stat = await this.fileService.resolve(dirname(logsPath));
|
|
219
|
+
if (stat.children) {
|
|
220
|
+
result.push(...( stat.children
|
|
221
|
+
.filter(stat => !isEqual(stat.resource, logsPath) && stat.isDirectory && /^\d{8}T\d{6}$/.test(stat.name))
|
|
222
|
+
.sort()
|
|
223
|
+
.reverse()
|
|
224
|
+
.map(d => d.resource)));
|
|
225
|
+
}
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
228
|
+
async getLogFiles(session) {
|
|
229
|
+
const stat = await this.fileService.resolve(session);
|
|
230
|
+
if (stat.children) {
|
|
231
|
+
return ( stat.children.filter(stat => !stat.isDirectory).map(stat => stat.resource));
|
|
232
|
+
}
|
|
233
|
+
return [];
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
export { SetLogLevelAction };
|