Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24280] iOS: CLI - Console logs cut initial words if starts with log levels substrings

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionNot Our Bug
Resolution Date2017-01-20T11:07:39.000+0000
Affected Version/sRelease 6.0.0, Release 6.0.1
Fix Version/sn/a
ComponentsiOS
Labelsconsole
ReporterRicardo Pereira
AssigneeEric Merriman
Created2017-01-05T12:01:51.000+0000
Updated2017-03-24T18:59:52.000+0000

Description

Note that this is a small issue! If the initial name of a object property starts with a substring that is similar to the log level, it cuts it's initial words
[INFO] :   SELECT 'appcelerator' as infomation, 'appcelerator' as logical, 'appcelerator' as warning
Will return a JS object:
var test = {
    infomation: "appcelerator",
    logical: "appcelerator",
    warning: "appcelerator"
};
This is the console log:
[INFO] :   (
[INFO] :   {
[INFO] :   mation = appcelerator;
[LOG] ical = appcelerator;
[WARN] :   ing = appcelerator;
[WARN] :   }
After the Appcelerator 4.8.0, I've noticed that the logs are always align at the left side without spaces/tabs before, before that, if the log is a JS object or array it should have some space or tab to distinguish from its parent *OLD WAY:*
[INFO] {
[INFO]      prop1: "val1",
[INFO]      prop2: "val2",
[INFO]      prop3: {
[INFO]            subprop: "subval"
[INFO]      }
[INFO] }
*NOW:*
[INFO] {
[INFO] prop1: "val1",
[INFO] prop2: "val2",
[INFO] prop3: {
[INFO] subprop: "subval"
[INFO] }
[INFO] }
!attachment-name.jpg|thumbnail!

Comments

  1. Hans Knöchel 2017-01-05

    Thats interesting. Is it on iOS, Android or Windows Phone? And which SDK version? Some more infos in the ticket details would be awesome, then we can move it to engineering! *EDIT*: I did a quick smoke-test using this demo-code:
       var win = Ti.UI.createWindow({
           backgroundColor: '#fff'
       });
       
       var btn = Ti.UI.createButton({
           title: 'Trigger Log'
       });
       
       btn.addEventListener('click', function() {
           Ti.API.info({
               infomation: "appcelerator",
               logical: "appcelerator",
               warning: "appcelerator"
           });
       });
       
       win.add(btn);
       win.open();
       
    The iOS output looks correctly:
       2017-01-05 13:20:51.751 Titanium[3132:87174] [INFO] {
           infomation = appcelerator;
           logical = appcelerator;
           warning = appcelerator;
       }
       
  2. Sharif AbuDarda 2017-01-05

    Hello [~hansknoechel], I tested your code in Android and iOS. In iOS I got as expected.
       [INFO] :   {
       [INFO] :       infomation = appcelerator;
       [INFO] :       logical = appcelerator;
       [INFO] :       warning = appcelerator;
       [INFO] :   }
       
    But, in Android i got
       [INFO]  [object Object]
       
    Not sure what the issue. Have any idea?
  3. Hans Knöchel 2017-01-05

    [~ricardo_jcp] Thanks for the updated ticket infos! So it's happening on iOS for you? Very interesting! And I see you're using the Studio, it be a Studio issue then. For the indentation, please file another ticket so we can fix that as well. Can you please try to reproduce the error on the CLI using appc run -p ios from your project directory? Thank you!
  4. Ricardo Pereira 2017-01-05

  5. Ricardo Pereira 2017-01-20

  6. Hans Knöchel 2017-01-20

    Thanks Ricardo. Please check [this Stackoverflow](http://stackoverflow.com/questions/3515523/javascript-how-to-generate-formatted-easy-to-read-json-straight-from-an-object) on how to indent your stringified code in JS. Thx!
  7. Lee Morris 2017-03-24

    Closing ticket with reference to the previous comments.

JSON Source