parent
5b7ea4cac9
commit
b206ac6ffd
|
@ -1,18 +0,0 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`cli invalid config support exits with statusCode 64 and logs a single line when config is invalid 1`] = `
|
||||
Array [
|
||||
Object {
|
||||
"@timestamp": "## @timestamp ##",
|
||||
"error": "## Error with stack trace ##",
|
||||
"level": "fatal",
|
||||
"message": "\\"unknown.key\\", \\"other.unknown.key\\", \\"other.third\\", \\"some.flat.key\\", and \\"some.array\\" settings were not applied. Check for spelling errors and ensure that expected plugins are installed.",
|
||||
"pid": "## PID ##",
|
||||
"tags": Array [
|
||||
"fatal",
|
||||
"root",
|
||||
],
|
||||
"type": "error",
|
||||
},
|
||||
]
|
||||
`;
|
|
@ -45,6 +45,9 @@ describe('cli invalid config support', function () {
|
|||
|
||||
expect(error).toBe(undefined);
|
||||
expect(status).toBe(64);
|
||||
expect(logLines).toMatchSnapshot();
|
||||
expect(logLines[0].message).toMatch('{ Error: "unknown.key", "other.unknown.key", "other.third", "some.flat.key", and "' +
|
||||
'some.array" settings were not applied. Check for spelling errors and ensure that expected plugins are installed.');
|
||||
expect(logLines[0].tags).toEqual(['fatal', 'root']);
|
||||
expect(logLines[0].type).toEqual('log');
|
||||
}, 20 * 1000);
|
||||
});
|
||||
|
|
|
@ -151,11 +151,11 @@ export default class TransformObjStream extends Stream.Transform {
|
|||
const message = get(event, 'error.message');
|
||||
data.message = message || 'Unknown error (no message)';
|
||||
}
|
||||
else if (event.data instanceof Error) {
|
||||
else if (event.error instanceof Error) {
|
||||
data.type = 'error';
|
||||
data.level = _.contains(event.tags, 'fatal') ? 'fatal' : 'error';
|
||||
data.error = serializeError(event.data);
|
||||
const message = get(event, 'data.message');
|
||||
data.error = serializeError(event.error);
|
||||
const message = get(event, 'error.message');
|
||||
data.message = message || 'Unknown error object (no message)';
|
||||
}
|
||||
else if (_.isPlainObject(event.data) && event.data.tmpl) {
|
||||
|
|
|
@ -132,9 +132,9 @@ describe('KbnLoggerJsonFormat', () => {
|
|||
expect(error).toEqual({});
|
||||
});
|
||||
|
||||
it('event data instanceof Error', async () => {
|
||||
it('event error instanceof Error', async () => {
|
||||
const event = {
|
||||
data: new Error('test error 2'),
|
||||
error: new Error('test error 2'),
|
||||
};
|
||||
const result = await createPromiseFromStreams([
|
||||
createListStream([event]),
|
||||
|
@ -145,16 +145,16 @@ describe('KbnLoggerJsonFormat', () => {
|
|||
expect(level).toBe('error');
|
||||
expect(message).toBe('test error 2');
|
||||
|
||||
expect(error.message).toBe(event.data.message);
|
||||
expect(error.name).toBe(event.data.name);
|
||||
expect(error.stack).toBe(event.data.stack);
|
||||
expect(error.code).toBe(event.data.code);
|
||||
expect(error.signal).toBe(event.data.signal);
|
||||
expect(error.message).toBe(event.error.message);
|
||||
expect(error.name).toBe(event.error.name);
|
||||
expect(error.stack).toBe(event.error.stack);
|
||||
expect(error.code).toBe(event.error.code);
|
||||
expect(error.signal).toBe(event.error.signal);
|
||||
});
|
||||
|
||||
it('event data instanceof Error - fatal', async () => {
|
||||
it('event error instanceof Error - fatal', async () => {
|
||||
const event = {
|
||||
data: new Error('test error 2'),
|
||||
error: new Error('test error 2'),
|
||||
tags: ['fatal', 'tag2']
|
||||
};
|
||||
const result = await createPromiseFromStreams([
|
||||
|
@ -167,16 +167,16 @@ describe('KbnLoggerJsonFormat', () => {
|
|||
expect(level).toBe('fatal');
|
||||
expect(message).toBe('test error 2');
|
||||
|
||||
expect(error.message).toBe(event.data.message);
|
||||
expect(error.name).toBe(event.data.name);
|
||||
expect(error.stack).toBe(event.data.stack);
|
||||
expect(error.code).toBe(event.data.code);
|
||||
expect(error.signal).toBe(event.data.signal);
|
||||
expect(error.message).toBe(event.error.message);
|
||||
expect(error.name).toBe(event.error.name);
|
||||
expect(error.stack).toBe(event.error.stack);
|
||||
expect(error.code).toBe(event.error.code);
|
||||
expect(error.signal).toBe(event.error.signal);
|
||||
});
|
||||
|
||||
it('event data instanceof Error, no message', async () => {
|
||||
it('event error instanceof Error, no message', async () => {
|
||||
const event = {
|
||||
data: new Error(''),
|
||||
error: new Error(''),
|
||||
};
|
||||
const result = await createPromiseFromStreams([
|
||||
createListStream([event]),
|
||||
|
@ -187,11 +187,11 @@ describe('KbnLoggerJsonFormat', () => {
|
|||
expect(level).toBe('error');
|
||||
expect(message).toBe('Unknown error object (no message)');
|
||||
|
||||
expect(error.message).toBe(event.data.message);
|
||||
expect(error.name).toBe(event.data.name);
|
||||
expect(error.stack).toBe(event.data.stack);
|
||||
expect(error.code).toBe(event.data.code);
|
||||
expect(error.signal).toBe(event.data.signal);
|
||||
expect(error.message).toBe(event.error.message);
|
||||
expect(error.name).toBe(event.error.name);
|
||||
expect(error.stack).toBe(event.error.stack);
|
||||
expect(error.code).toBe(event.error.code);
|
||||
expect(error.signal).toBe(event.error.signal);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue