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);
|
||||
} else if (Object.prototype.isPrototypeOf(arg) || Array.isArray(arg)) {
|
||||
arg = inspect(arg, {
|
||||
customInspect: true,
|
||||
prettyPrint: false
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1121,13 +1121,11 @@ global.DEFINE_MODULE('internal', (function () {
|
|||
var keys;
|
||||
|
||||
try {
|
||||
keys = Object.keys(object);
|
||||
// try to detect an ES6 class. note that this won't work 100% correct
|
||||
if (object.constructor && object.constructor.name !== 'Object') {
|
||||
if (object.constructor && object.constructor !== Object) {
|
||||
// probably an object of an ES6 class
|
||||
keys = Object.getOwnPropertyNames(Object.getPrototypeOf(object));
|
||||
} else {
|
||||
// other object
|
||||
keys = Object.keys(object);
|
||||
context.output += `[${object.constructor.name}]`;
|
||||
}
|
||||
} catch (err) {
|
||||
// ES6 proxy objects don't support key enumeration
|
||||
|
@ -1141,7 +1139,7 @@ global.DEFINE_MODULE('internal', (function () {
|
|||
// hide ctor
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (useColor) {
|
||||
context.output += colors.COLOR_PUNCTUATION;
|
||||
}
|
||||
|
@ -1544,7 +1542,7 @@ global.DEFINE_MODULE('internal', (function () {
|
|||
limitString: false,
|
||||
names: [],
|
||||
output: '',
|
||||
prettyPrint: true,
|
||||
prettyPrint: !options || options.prettyPrint !== false,
|
||||
path: '~',
|
||||
seen: [],
|
||||
showFunction: true,
|
||||
|
@ -1552,10 +1550,6 @@ global.DEFINE_MODULE('internal', (function () {
|
|||
useToString: false
|
||||
};
|
||||
|
||||
if (options && options.hasOwnProperty('prettyPrint')) {
|
||||
context.prettyPrint = options.prettyPrint;
|
||||
}
|
||||
|
||||
printRecursive(object, context);
|
||||
|
||||
return context.output;
|
||||
|
|
Loading…
Reference in New Issue