Skip to content

Commit 7b8a39b

Browse files
authored
Merge pull request #87 from fullstack-build/master
Latest version
2 parents 4560d7c + 77ab7c9 commit 7b8a39b

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tslog",
3-
"version": "3.0.5",
3+
"version": "3.1.1",
44
"description": "📝 Expressive TypeScript Logger for Node.js: Pretty errors, stack traces, code frames, and JSON output to attachable transports.",
55
"main": "./dist/cjs/index.js",
66
"module": "./dist/esm/index.js",

src/LoggerHelper.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ export class LoggerHelper {
294294
return LoggerHelper.cloneObjectRecursively(value, maskValuesFn, done);
295295
}
296296
}) as unknown) as T;
297+
} else if (Buffer.isBuffer(obj)) {
298+
return obj as T;
297299
} else {
298300
Object.getOwnPropertyNames(obj).forEach((currentKey: string | number) => {
299301
if (!done.includes(obj[currentKey])) {

src/LoggerWithoutCallSite.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,19 @@ export class LoggerWithoutCallSite {
640640
: "";
641641

642642
const errorObject: IErrorObject = argument as IErrorObject;
643-
if (typeof argument === "object" && errorObject?.isError === true) {
643+
if (argument == null) {
644+
std.write(
645+
typeStr +
646+
this._inspectAndHideSensitive(
647+
argument as null,
648+
this.settings.prettyInspectOptions
649+
) +
650+
" "
651+
);
652+
} else if (
653+
typeof argument === "object" &&
654+
errorObject?.isError === true
655+
) {
644656
this._printPrettyError(std, errorObject);
645657
} else if (
646658
typeof argument === "object" &&
@@ -852,7 +864,7 @@ export class LoggerWithoutCallSite {
852864
argumentsArray: logObject.argumentsArray.map(
853865
(argument: unknown | IErrorObject) => {
854866
const errorObject: IErrorObject = argument as IErrorObject;
855-
if (typeof argument === "object" && errorObject.isError) {
867+
if (typeof argument === "object" && errorObject?.isError) {
856868
return {
857869
...errorObject,
858870
nativeError: undefined,

tests/parameter.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,12 @@ describe("Logger: Parameter", () => {
127127
expect(doesLogContain(stdOut, "object: ")).toBeTruthy();
128128
expect(doesLogContain(stdOut, "recursive: [Circular")).toBeTruthy();
129129
});
130+
131+
test("buffer", (): void => {
132+
const buffer = Buffer.from("foo");
133+
logger.silly(buffer);
134+
135+
expect(doesLogContain(stdOut, "SILLY")).toBeTruthy();
136+
expect(doesLogContain(stdOut, "<Buffer 66 6f 6f>")).toBeTruthy();
137+
});
130138
});

0 commit comments

Comments
 (0)