mirror of https://gitee.com/bigwinds/arangodb
More meaningful object logging
Don't log inherited attributes. Do log constructor name for class instances. Use _PRINT methods if available except when using console.dir.
This commit is contained in:
parent
ab177612a5
commit
23ac54183c
|
@ -104,6 +104,7 @@ global.DEFINE_MODULE('console', (function () {
|
||||||
arg = String(arg);
|
arg = String(arg);
|
||||||
} else if (Object.prototype.isPrototypeOf(arg) || Array.isArray(arg)) {
|
} else if (Object.prototype.isPrototypeOf(arg) || Array.isArray(arg)) {
|
||||||
arg = inspect(arg, {
|
arg = inspect(arg, {
|
||||||
|
customInspect: true,
|
||||||
prettyPrint: false
|
prettyPrint: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1121,13 +1121,11 @@ global.DEFINE_MODULE('internal', (function () {
|
||||||
var keys;
|
var keys;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// try to detect an ES6 class. note that this won't work 100% correct
|
|
||||||
if (object.constructor && object.constructor.name !== 'Object') {
|
|
||||||
// probably an object of an ES6 class
|
|
||||||
keys = Object.getOwnPropertyNames(Object.getPrototypeOf(object));
|
|
||||||
} else {
|
|
||||||
// other object
|
|
||||||
keys = Object.keys(object);
|
keys = Object.keys(object);
|
||||||
|
// try to detect an ES6 class. note that this won't work 100% correct
|
||||||
|
if (object.constructor && object.constructor !== Object) {
|
||||||
|
// probably an object of an ES6 class
|
||||||
|
context.output += `[${object.constructor.name}]`;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// ES6 proxy objects don't support key enumeration
|
// ES6 proxy objects don't support key enumeration
|
||||||
|
@ -1544,7 +1542,7 @@ global.DEFINE_MODULE('internal', (function () {
|
||||||
limitString: false,
|
limitString: false,
|
||||||
names: [],
|
names: [],
|
||||||
output: '',
|
output: '',
|
||||||
prettyPrint: true,
|
prettyPrint: !options || options.prettyPrint !== false,
|
||||||
path: '~',
|
path: '~',
|
||||||
seen: [],
|
seen: [],
|
||||||
showFunction: true,
|
showFunction: true,
|
||||||
|
@ -1552,10 +1550,6 @@ global.DEFINE_MODULE('internal', (function () {
|
||||||
useToString: false
|
useToString: false
|
||||||
};
|
};
|
||||||
|
|
||||||
if (options && options.hasOwnProperty('prettyPrint')) {
|
|
||||||
context.prettyPrint = options.prettyPrint;
|
|
||||||
}
|
|
||||||
|
|
||||||
printRecursive(object, context);
|
printRecursive(object, context);
|
||||||
|
|
||||||
return context.output;
|
return context.output;
|
||||||
|
|
Loading…
Reference in New Issue