Skip to content

Commit

Permalink
Catch @hapi/podium errors (#84575)
Browse files Browse the repository at this point in the history
  • Loading branch information
watson authored Dec 3, 2020
1 parent 155d150 commit 770a005
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/kbn-legacy-logging/src/legacy_logging_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,18 @@ export class LegacyLoggingServer {
public log({ level, context, message, error, timestamp, meta = {} }: LogRecord) {
const { tags = [], ...metadata } = meta;

this.events.emit('log', {
data: getDataToLog(error, metadata, message),
tags: [getLegacyLogLevel(level), ...context.split('.'), ...tags],
timestamp: timestamp.getTime(),
});
this.events
.emit('log', {
data: getDataToLog(error, metadata, message),
tags: [getLegacyLogLevel(level), ...context.split('.'), ...tags],
timestamp: timestamp.getTime(),
})
// @ts-expect-error @hapi/podium emit is actually an async function
.catch((err) => {
// eslint-disable-next-line no-console
console.error('An unexpected error occurred while writing to the log:', err.stack);
process.exit(1);
});
}

public stop() {
Expand Down

0 comments on commit 770a005

Please sign in to comment.