Skip to content

Commit 3e5612a

Browse files
committed
2 parents 3a0866e + 00bd40d commit 3e5612a

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

src/BaseLogger.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ export class BaseLogger<LogObj> {
207207
? new Date(source.getTime())
208208
: source != null && typeof source === "object"
209209
? Object.getOwnPropertyNames(source).reduce((o, prop) => {
210-
Object.defineProperty(o, prop, Object.getOwnPropertyDescriptor(source, prop)!);
211210
// mask
212211
o[prop] = keys.includes(this.settings?.maskValuesOfKeysCaseInsensitive !== true ? prop : prop.toLowerCase())
213212
? this.settings.maskPlaceholder
Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
1-
import { ok } from "assert";
21
import "ts-jest";
2+
import { ok } from "assert";
33
import { Logger } from "../../src/index.js";
4-
import { mockConsoleLog } from "./helper.js";
4+
import { getConsoleLog, mockConsoleLog } from "./helper.js";
55

66
class MissingSetter {
7-
get test(): string {
7+
get testProp(): string {
88
return "test";
99
}
1010
}
1111

1212
const missingSetter = {
13-
get test(): string {
13+
get testProp(): string {
1414
return "test";
15-
}
16-
}
15+
},
16+
};
1717

1818
describe("Getters and setters", () => {
1919
beforeEach(() => {
2020
mockConsoleLog(true, false);
2121
});
22-
test("[class] should not print getters", (): void => {
22+
23+
test("[class] should not print getters on class instance (prototype)", (): void => {
24+
// Node.js issue: https://github.com/nodejs/node/issues/30183
2325
const logger = new Logger({
24-
type: "hidden",
26+
type: "pretty",
2527
});
2628
const missingSetterObj = new MissingSetter();
27-
2829
const result = logger.info(missingSetterObj);
29-
3030
ok(result);
31-
Object.keys(result).forEach((key) => {
32-
expect(key).not.toBe("test");
33-
});
31+
expect(Object.keys(result)).not.toContain("testProp");
32+
expect(getConsoleLog()).not.toContain("testProp");
3433
});
34+
3535
test("[object] should print getters", (): void => {
3636
const logger = new Logger({
37-
type: "hidden",
37+
type: "pretty",
3838
});
3939
const result = logger.info(missingSetter);
40-
expect(result).toContain("test");
40+
ok(result);
41+
expect(Object.keys(result)).toContain("testProp");
42+
expect(getConsoleLog()).toContain("testProp");
4143
});
4244
});

0 commit comments

Comments
 (0)