Path: blob/main/src/vs/workbench/services/extensions/common/remoteConsoleUtil.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { IRemoteConsoleLog, parse } from '../../../../base/common/console.js';6import { ILogService } from '../../../../platform/log/common/log.js';78export function logRemoteEntry(logService: ILogService, entry: IRemoteConsoleLog, label: string | null = null): void {9const args = parse(entry).args;10let firstArg = args.shift();11if (typeof firstArg !== 'string') {12return;13}1415if (!entry.severity) {16entry.severity = 'info';17}1819if (label) {20if (!/^\[/.test(label)) {21label = `[${label}]`;22}23if (!/ $/.test(label)) {24label = `${label} `;25}26firstArg = label + firstArg;27}2829switch (entry.severity) {30case 'log':31case 'info':32logService.info(firstArg, ...args);33break;34case 'warn':35logService.warn(firstArg, ...args);36break;37case 'error':38logService.error(firstArg, ...args);39break;40}41}4243export function logRemoteEntryIfError(logService: ILogService, entry: IRemoteConsoleLog, label: string): void {44const args = parse(entry).args;45const firstArg = args.shift();46if (typeof firstArg !== 'string' || entry.severity !== 'error') {47return;48}4950if (!/^\[/.test(label)) {51label = `[${label}]`;52}53if (!/ $/.test(label)) {54label = `${label} `;55}5657logService.error(label + firstArg, ...args);58}596061