Skip to content

Commit bcaba31

Browse files
committed
chore: outout channel append line type
1 parent e747c92 commit bcaba31

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

packages/output/src/browser/output.channel.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,18 @@ export class OutputChannel extends Disposable {
157157

158158
appendLine(line: string): void {
159159
let value = line;
160-
if (!line.endsWith('\r\n')) {
161-
value = line + '\r\n';
160+
if (typeof line !== 'string') {
161+
try {
162+
value = JSON.stringify(line);
163+
} catch (e) {
164+
value = `[${typeof line}]`;
165+
}
166+
}
167+
168+
if (!value.endsWith('\r\n')) {
169+
value = value + '\r\n';
162170
}
171+
163172
this.eventBus.fire(
164173
new ContentChangeEvent(
165174
new ContentChangeEventPayload(this.name, ContentChangeType.appendLine, value, this.outputLines),
@@ -169,7 +178,7 @@ export class OutputChannel extends Disposable {
169178
if (this.shouldLogToBrowser) {
170179
// eslint-disable-next-line no-console
171180
console.log(
172-
`%c[${this.name}]` + `%c ${line}}`,
181+
`%c[${this.name}]` + `%c ${value}}`,
173182
'background:rgb(50, 150, 250); color: #fff',
174183
'background: none; color: inherit',
175184
);

0 commit comments

Comments
 (0)