Skip to content

Commit

Permalink
[logging/json] use merge from kbn/std (#86330)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
jbudz and kibanamachine committed Dec 28, 2020
1 parent e9cbbe9 commit 2cff2f7
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions src/core/server/logging/layouts/json_layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import moment from 'moment-timezone';
import { merge } from 'lodash';
import { merge } from '@kbn/std';
import { schema } from '@kbn/config-schema';
import { LogRecord, Layout } from '@kbn/logging';

Expand Down Expand Up @@ -53,22 +53,19 @@ export class JsonLayout implements Layout {
}

public format(record: LogRecord): string {
return JSON.stringify(
merge(
{
'@timestamp': moment(record.timestamp).format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
message: record.message,
error: JsonLayout.errorToSerializableObject(record.error),
log: {
level: record.level.id.toUpperCase(),
logger: record.context,
},
process: {
pid: record.pid,
},
},
record.meta
)
);
const log = {
'@timestamp': moment(record.timestamp).format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
message: record.message,
error: JsonLayout.errorToSerializableObject(record.error),
log: {
level: record.level.id.toUpperCase(),
logger: record.context,
},
process: {
pid: record.pid,
},
};
const output = record.meta ? merge(log, record.meta) : log;
return JSON.stringify(output);
}
}

0 comments on commit 2cff2f7

Please sign in to comment.