Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/services/extensions/common/remoteConsoleUtil.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 { IRemoteConsoleLog, parse } from '../../../../base/common/console.js';
7
import { ILogService } from '../../../../platform/log/common/log.js';
8
9
export function logRemoteEntry(logService: ILogService, entry: IRemoteConsoleLog, label: string | null = null): void {
10
const args = parse(entry).args;
11
let firstArg = args.shift();
12
if (typeof firstArg !== 'string') {
13
return;
14
}
15
16
if (!entry.severity) {
17
entry.severity = 'info';
18
}
19
20
if (label) {
21
if (!/^\[/.test(label)) {
22
label = `[${label}]`;
23
}
24
if (!/ $/.test(label)) {
25
label = `${label} `;
26
}
27
firstArg = label + firstArg;
28
}
29
30
switch (entry.severity) {
31
case 'log':
32
case 'info':
33
logService.info(firstArg, ...args);
34
break;
35
case 'warn':
36
logService.warn(firstArg, ...args);
37
break;
38
case 'error':
39
logService.error(firstArg, ...args);
40
break;
41
}
42
}
43
44
export function logRemoteEntryIfError(logService: ILogService, entry: IRemoteConsoleLog, label: string): void {
45
const args = parse(entry).args;
46
const firstArg = args.shift();
47
if (typeof firstArg !== 'string' || entry.severity !== 'error') {
48
return;
49
}
50
51
if (!/^\[/.test(label)) {
52
label = `[${label}]`;
53
}
54
if (!/ $/.test(label)) {
55
label = `${label} `;
56
}
57
58
logService.error(label + firstArg, ...args);
59
}
60
61