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

Commit 2dcb670

Browse files
committed
Replace reqId with req.id (if it is available)
1 parent cb4541f commit 2dcb670

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/formatters/json.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import { BaseFormatter, type LogRecord } from './base';
2525
import { levelLabelNames, omit } from '../utils';
2626
import { EOL, userInfo } from 'os';
27-
import { Lazy } from '@noelware/utils';
27+
import { hasOwnProperty, Lazy } from '@noelware/utils';
2828

2929
const username = new Lazy(() => {
3030
const info = userInfo();
@@ -42,6 +42,11 @@ export class JsonFormatter extends BaseFormatter {
4242
};
4343

4444
const rest = omit(record, ['hostname', 'level', 'msg', 'time', 'name']);
45+
if (hasOwnProperty(rest, 'reqId') && hasOwnProperty(rest, 'req') && rest.req.id === null) {
46+
rest.req.id = rest.reqId;
47+
delete rest.reqId;
48+
}
49+
4550
return (
4651
JSON.stringify({
4752
...payload,

0 commit comments

Comments
 (0)