Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23237] Windows: Inconsistencies in Ti.API.log

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-04-29T14:35:19.000+0000
Affected Version/sRelease 5.3.0, Release 5.2.2
Fix Version/sRelease 5.3.0
ComponentsWindows
Labelsparity, qe-5.3.0
ReporterEwan Harris
AssigneeKota Iguchi
Created2016-04-19T18:02:40.000+0000
Updated2016-05-03T15:27:42.000+0000

Description

Description

*This is not a regression* When using Ti.API.log there are some inconsistencies with other platforms. Firstly, by default it appears that it will log at the debug level when the specified log level is not recognised rather than info, with the log message prefixed with the unrecognised string Also it appears that any logging performed using Ti.API.log will always take on the log level of the last statement, so if I log Ti.API.error('log') and then Ti.API.log('info, 'log') the Ti.API.log statement will be printed out at the error logging level. See below for an example
Ti.API.log('meh','I am default log');

Ti.API.error('logging to change other Ti.API.log statements');

Ti.API.log('error','I am error from log');
Ti.API.log('debug', 'I am debug from log');
Ti.API.log('info', 'I am info from log');
Ti.API.log('trace', 'I am trace from log');
Ti.API.log('warn', 'I am warn from log');
[DEBUG] I am default log
[ERROR] logging to change other Ti.API.log statements
[ERROR] I am error from log
[ERROR] I am debug from log
[ERROR] I am info from log
[ERROR] I am trace from log
[ERROR] I am warn from log
[INFO]  [meh]  I am default log
[ERROR] logging to change other Ti.API.log statements
[ERROR] I am error from log
[INFO]  I am info from log
[WARN]  I am warn from log

Steps to reproduce

1. Using the code above build to a Windows emulator using appc run -p windows -T wp-emulator (This also happens with wp-device and ws-local)

Actual result

All logging takes place at the DEBUG level by default

A log can change the log level for logs that follow it

An unrecognised level is not logged as [INFO] [level]

Expected result

#The logging should take place at the level specified in the code

An unrecognised level should be logged as [INFO] [level]

A log should not be able to change the log level of logs that follow it

Comments

  1. Kota Iguchi 2016-04-20

    On iOS Ti.API.log('meh', 'I am default log'); prints nothing. I'll make Windows align with iOS.
        [ERROR] logging to change other Ti.API.log statements
        [ERROR] I am error from log
        [INFO]  I am info from log
        [WARN]  I am warn from log
       
  2. Kota Iguchi 2016-04-20

    https://github.com/appcelerator/titanium_mobile_windows/pull/637
  3. Jörgen Buder 2016-04-20

  4. Harry Bryant 2016-04-27

    [~kota] Upon investigation, Ti.API.log('meh', 'I am default log'); appears to print nothing on iOS unless you set the log-level to DEBUG or TRACE, it actually seems to print the custom log message under [DEBUG]. However, when tested on windows it does not print anything at all. Below is the following console at TRACE level on *Windows*:
       [ERROR] :  logging to change other Ti.API.log statements
       [ERROR] :  I am error from log
       [DEBUG] :  I am debug from log
       [INFO] :   I am info from log
       [TRACE] :  I am trace from log
       [WARN] :   I am warn from log
       
    console at TRACE level on *iOS*:
       [DEBUG] :  [MEH] I am default log
       [INFO] :   I am info from log
       [ERROR] :  logging to change other Ti.API.log statements
       [ERROR] :  I am error from log
       [DEBUG] :  I am debug from log
       [TRACE] :  I am trace from log
       [WARN] :   I am warn from log
       
    To maintain consistency between the platforms, I would suggest either: 1. Android be changed to match the behaviour seen on Windows, and to remove the custom log messages on iOS appearing as [DEBUG]. 2. Change iOS & Windows to support custom log messages, to match Android. Tested on: Windows 10 Pro Windows Phone 10.0 & 8.1 (Microsoft Lumia 640 LTE) Appc Studio: 4.6.0.201604081249 Ti SDK: 5.3.0.v20160421080259 Appc NPM: 4.2.5-3 Appc Core: 5.3.0-36 Node: v4.4.2
  5. Christopher Williams 2016-04-28

    [~kota] So the difference here seems to be that we ignore custom log levels, and iOS spits them out under [DEBUG] [CUSTOM_UPPERCASE]. So we should match that on Windows. [~htbryant] As for Android, well I think another ticket should be opened up for parity to fix on that platform. We considered iOS to be the "reference" platform in this case.
  6. Kota Iguchi 2016-04-29

    https://github.com/appcelerator/titanium_mobile_windows/pull/650 https://github.com/appcelerator/titanium_mobile_windows/pull/651
  7. Harry Bryant 2016-04-29

  8. Harry Bryant 2016-05-02

    Verified as fixed Tested on: Windows 10 Pro Windows Phone 10.0 (Microsoft Lumia 640 LTE) Appc Studio: 4.6.0.201604290815 Ti SDK: 5.3.0.v20160430043601 Appc NPM: 4.2.5-5 Appc Core: 5.3.0-40 Node: v4.4.2 *Closing Ticket.*

JSON Source