Skip to content

Commit 67c981b

Browse files
authored
fix: use pino file to log to stdout when logflare is disabled (uses a… (#674)
* fix: use pino file to log to stdout when logflare is disabled (uses a worker thread) * expose real http status code
1 parent bf3d59d commit 67c981b

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/internal/errors/codes.ts

+3
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,14 @@ export function isStorageError(errorType: ErrorCode, error: any): error is Stora
388388

389389
export function normalizeRawError(error: any) {
390390
if (error instanceof Error) {
391+
const statusCode =
392+
error instanceof StorageBackendError && error.httpStatusCode ? error.httpStatusCode : 0
391393
return {
392394
raw: JSON.stringify(error),
393395
name: error.name,
394396
message: error.message,
395397
stack: error.stack,
398+
statusCode,
396399
}
397400
}
398401

src/internal/monitoring/logger.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,15 @@ export const logSchema = {
100100
}
101101

102102
export function buildTransport(): pino.TransportMultiOptions | undefined {
103+
const stdOutTarget = {
104+
level: logLevel || 'info',
105+
target: 'pino/file',
106+
// omitting options.destination logs to stdout using a worker thread
107+
options: {},
108+
}
109+
103110
if (!logflareEnabled) {
104-
return undefined
111+
return { targets: [stdOutTarget] }
105112
}
106113

107114
if (!logflareApiKey) {
@@ -119,11 +126,7 @@ export function buildTransport(): pino.TransportMultiOptions | undefined {
119126
target: './logflare',
120127
options: {},
121128
},
122-
{
123-
level: logLevel || 'info',
124-
target: 'pino/file',
125-
options: {},
126-
},
129+
stdOutTarget,
127130
],
128131
}
129132
}

0 commit comments

Comments
 (0)