Skip to content

Commit

Permalink
Support Buffers, fix #86
Browse files Browse the repository at this point in the history
  • Loading branch information
terehov committed Feb 3, 2021
1 parent a9982d0 commit 5af9b6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/LoggerHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ export class LoggerHelper {
return LoggerHelper.cloneObjectRecursively(value, maskValuesFn, done);
}
}) as unknown) as T;
} else if (Buffer.isBuffer(obj)) {
return obj as T;
} else {
Object.getOwnPropertyNames(obj).forEach((currentKey: string | number) => {
if (!done.includes(obj[currentKey])) {
Expand Down
8 changes: 8 additions & 0 deletions tests/parameter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,12 @@ describe("Logger: Parameter", () => {
expect(doesLogContain(stdOut, "object: ")).toBeTruthy();
expect(doesLogContain(stdOut, "recursive: [Circular")).toBeTruthy();
});

test("buffer", (): void => {
const buffer = Buffer.from("foo");
logger.silly(buffer);

expect(doesLogContain(stdOut, "SILLY")).toBeTruthy();
expect(doesLogContain(stdOut, "<Buffer 66 6f 6f>")).toBeTruthy();
});
});

0 comments on commit 5af9b6c

Please sign in to comment.