Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27345] Improve console debugging capabilities with util.inspect

GitHub Issuen/a
TypeImprovement
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2019-10-04T14:30:02.000+0000
Affected Version/sRelease 8.1.0
Fix Version/sRelease 8.3.0
ComponentsCore
Labelsn/a
ReporterJan Vennemann
AssigneeJan Vennemann
Created2019-08-20T20:33:14.000+0000
Updated2019-10-04T14:30:02.000+0000

Description

Debugging with any of the console or Ti.API logging functions needs some improvement when it comes to printing object structures. Since 8.1.0.GA printing an object simply outputs [object Object] in some cases which is not very useful. With TIMOB-26670 we now have util.inspect available and we should hook that up with console and Ti.API just like Node.js does for extensive logging/debugging capabilities. A few examples:
const a = {};
a.b = a;
console.log(a); // crashes on 8.0.1.GA, or just prints "[object Object]" on 8.1.0.GA

const b = {
  foo: 'bar'
}
console.log(b); // prints "{ foo: 'bar' }" on 8.0.1.GA, or just "[object Object]" on 8.1.0.GA

const map = new Map();
map.set('foo', 'bar');
console.log(map); // prints "{}" on 8.0.1.GA, or just "[object Map]" on 8.1.0.GA

Comments

  1. Jan Vennemann 2019-09-26

    PR: https://github.com/appcelerator/titanium_mobile/pull/11165
  2. Samir Mohammed 2019-09-26

    FR Passed: Waiting on Jenkins build
  3. Christopher Williams 2019-10-03

    merged to master
  4. Sohail Saddique 2019-10-04

    *Verified working* Test environment Studio Ver: 5.1.4.201909061933 SDK Ver: 8.3.0.v20191003144543 OS Ver: 10.14.6 Appc NPM: 4.2.15 Appc CLI: 7.1.1 Node Ver: 10.16.3 NPM Ver: 6.11.3 Emulator: ⇨ Pixel 3 (Android 9) *Output*
       [INFO]  <ref *1> { b: [Circular *1] }
       [INFO]  { foo: 'bar' }
       [INFO]  Map { 'foo' => 'bar' }
       
    Ticket closed.

JSON Source