Skip to content

Commit b92cbb8

Browse files
author
spalger
committed
collect log messages as strings instead of message objects
1 parent dce409f commit b92cbb8

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

packages/kbn-dev-utils/src/tooling_log/tooling_log_collecting_writer.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,20 @@
1717
* under the License.
1818
*/
1919

20-
import { Writer } from './writer';
21-
import { Message } from './message';
20+
import { ToolingLogTextWriter } from './tooling_log_text_writer';
2221

23-
export class ToolingLogCollectingWriter implements Writer {
24-
messages: Message[] = [];
22+
export class ToolingLogCollectingWriter extends ToolingLogTextWriter {
23+
messages: string[] = [];
2524

26-
constructor() {}
27-
28-
write(message: Message) {
29-
this.messages.push(message);
30-
return true;
25+
constructor() {
26+
super({
27+
level: 'verbose',
28+
writeTo: {
29+
write: msg => {
30+
// trim trailing new line
31+
this.messages.push(msg.slice(0, -1));
32+
},
33+
},
34+
});
3135
}
3236
}

packages/kbn-test/src/failed_tests_reporter/report_failure.test.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,7 @@ describe('createFailureIssue()', () => {
7272
`);
7373
expect(writer.messages).toMatchInlineSnapshot(`
7474
Array [
75-
Object {
76-
"args": Array [
77-
"Created issue undefined",
78-
],
79-
"indent": 0,
80-
"type": "info",
81-
},
75+
" info Created issue undefined",
8276
]
8377
`);
8478
});
@@ -145,13 +139,7 @@ describe('updatedFailureIssue()', () => {
145139
`);
146140
expect(writer.messages).toMatchInlineSnapshot(`
147141
Array [
148-
Object {
149-
"args": Array [
150-
"Updated issue https://github.com/issues/1234, failCount: 11",
151-
],
152-
"indent": 0,
153-
"type": "info",
154-
},
142+
" info Updated issue https://github.com/issues/1234, failCount: 11",
155143
]
156144
`);
157145
});

0 commit comments

Comments
 (0)