Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
[1.2.2] Don't fail if stack is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
auguwu committed Jan 28, 2023
1 parent 7240ff2 commit 1b11277
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@augu/pino-transport",
"description": "🐻‍❄️🌲 Pino transport that roughly matches what I like to see in my logs",
"version": "1.2.1",
"version": "1.2.2",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
Expand Down
15 changes: 14 additions & 1 deletion src/formatters/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,20 @@ export class DefaultFormatter extends BaseFormatter {
{
buf += ' ';
const attrs = Object.entries(
omit(record, ['hostname', 'level', 'msg', 'time', 'error', 'req', 'res', 'err', 'pid', 'name'])
omit(record, [
'hostname',
'level',
'msg',
'time',
'error',
'req',
'res',
'err',
'pid',
'name',
'reqId',
'responseTime'
])
)
.map(([key, value]) => gray(`[${key}=>${value}]`))
.join(' ');
Expand Down
31 changes: 17 additions & 14 deletions src/serializers/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,23 @@ export const createErrorSerializer =
const result: SerializedError = {
name: error.name,
message: error.message,
stack: stack
.filter((s) => !s.getFileName()?.startsWith('node:') ?? true)
.map((site) => ({
eval_invocation: site.isEval(),
this_context: site.getTypeName() || 'Object',
constructor: site.isConstructor(),
function: site.getFunctionName() || '<anonymous>',
toplevel: site.isToplevel(),
native: site.isNative(),
method: site.getMethodName() || '<unknown>',
file: site.getFileName() || '',
line: site.getLineNumber() || -1,
col: site.getColumnNumber() || -1
}))
stack:
stack !== undefined
? stack
.filter((s) => !s.getFileName()?.startsWith('node:') ?? true)
.map((site) => ({
eval_invocation: site.isEval(),
this_context: site.getTypeName() || 'Object',
constructor: site.isConstructor(),
function: site.getFunctionName() || '<anonymous>',
toplevel: site.isToplevel(),
native: site.isNative(),
method: site.getMethodName() || '<unknown>',
file: site.getFileName() || '',
line: site.getLineNumber() || -1,
col: site.getColumnNumber() || -1
}))
: []
};

Object.defineProperty(result, originalErrorSymbol, {
Expand Down

0 comments on commit 1b11277

Please sign in to comment.