Skip to content

Commit ae4abbd

Browse files
fix: logger changes broke trace and some hooks
`--log trace` is broken as we are tring to iterate over object created with `Object.create(null)`. It uses the prototype of null, so it does not have `hasOwnProperty` method. Filter such objects from our checks in logger. Also nativescript-plugin-firebase uses logger.out, which has been deleted, get it back for backwards compatibility and delete it in 6.0.0 release.
1 parent 09b6908 commit ae4abbd

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/common/logger/logger.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ export class Logger implements ILogger {
8181
this.logMessage(args, LoggerLevel.INFO);
8282
}
8383

84+
/**
85+
* DEPRECATED
86+
* Present only for backwards compatibility as some plugins (nativescript-plugin-firebase)
87+
* use $logger.out in their hooks
88+
*/
89+
out(...args: any[]): void {
90+
this.info(args);
91+
}
92+
8493
debug(...args: any[]): void {
8594
const encodedArgs: string[] = this.getPasswordEncodedArguments(args);
8695
this.logMessage(encodedArgs, LoggerLevel.DEBUG);
@@ -159,7 +168,8 @@ export class Logger implements ILogger {
159168
const result: any = {};
160169
const cleanedData = _.cloneDeep(data);
161170

162-
const dataToCheck = data.filter(el => typeof el === "object");
171+
// objects created with Object.create(null) do not have `hasOwnProperty` function
172+
const dataToCheck = data.filter(el => typeof el === "object" && el.hasOwnProperty && typeof el.hasOwnProperty === "function");
163173

164174
for (const element of dataToCheck) {
165175
if (opts.length === 0) {

0 commit comments

Comments
 (0)