[TIMOB-8424] Ti API: Define cross platform logging API
GitHub Issue | n/a |
---|---|
Type | Story |
Priority | High |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2020-01-08T18:31:44.000+0000 |
Affected Version/s | Release 2.0.0, Release 3.0.2 |
Fix Version/s | n/a |
Components | TiAPI |
Labels | qe-sdk3.0.2 |
Reporter | Arthur Evans |
Assignee | Unknown |
Created | 2012-03-29T13:49:50.000+0000 |
Updated | 2020-01-08T18:31:44.000+0000 |
Description
Currently, Ti.API defines several redundant logging methods. These include:
Ti.API.notice -- duplicates Ti.API.info but with a less-obvious name
Ti.API.critical, Ti.API.fatal -- duplicate Ti.API.error
We need a larger discussion to lay out how logging should work and look like across all platforms.
Sample Code:
/* console */
console.log();
console.log('console.log');
console.log(['console.log.0', 'console.log.1']);
console.debug();
console.debug('console.debug');
console.debug(['console.debug.0', 'console.debug.1']);
console.info();
console.info('console.info');
console.info(['console.info.0', 'console.info.1']);
console.warn();
console.warn('console.warn');
console.warn(['console.warn.0', 'console.warn.1']);
console.error();
console.error('console.error');
console.error(['console.error.0', 'console.error.1']);
/* Ti.API */
Ti.API.trace();
Ti.API.trace('Ti.API.trace');
Ti.API.trace(['Ti.API.trace.0', 'Ti.API.trace.1']);
Ti.API.debug();
Ti.API.debug('Ti.API.debug');
Ti.API.debug(['Ti.API.debug.0', 'Ti.API.debug.1']);
Ti.API.info();
Ti.API.info('Ti.API.info');
Ti.API.info(['Ti.API.info.0', 'Ti.API.info.1']);
Ti.API.warn();
Ti.API.warn('Ti.API.warn');
Ti.API.warn(['Ti.API.warn.0', 'Ti.API.warn.1']);
Ti.API.error();
Ti.API.error('Ti.API.error');
Ti.API.error(['Ti.API.error.0', 'Ti.API.error.1']);
/* Ti.API.log */
Ti.API.log();
Ti.API.log('trace');
Ti.API.log('trace', 'Ti.API.log.trace');
Ti.API.log('trace', ['Ti.API.trace.0', 'Ti.API.trace.1']);
Ti.API.log('debug');
Ti.API.log('debug', 'Ti.API.log.debug');
Ti.API.log('debug', ['Ti.API.debug.0', 'Ti.API.debug.1']);
Ti.API.log('info');
Ti.API.log('info', 'Ti.API.log.info');
Ti.API.log('info', ['Ti.API.info.0', 'Ti.API.info.1']);
Ti.API.log('warn');
Ti.API.log('warn', 'Ti.API.log.warn');
Ti.API.log('warn', ['Ti.API.warn.0', 'Ti.API.warn.1']);
Ti.API.log('error');
Ti.API.log('error', 'Ti.API.log.error');
Ti.API.log('error', ['Ti.API.error.0', 'Ti.API.error.1']);
Ti.API.log('log');
Ti.API.log('log', 'Ti.API.log.log');
Ti.API.log('log', ['Ti.API.log.0', 'Ti.API.log.1']);
/* Ti.iOS.API */
if(Ti.Platform.osname == 'iphone' || Ti.Platform.osname == 'ipad')
{
Ti.API.timestamp();
Ti.API.timestamp('Ti.API.timestamp');
Ti.API.timestamp(['Ti.API.timestamp.0', 'Ti.API.timestamp.1']);
Ti.API.log('timestamp');
Ti.API.log('timestamp', 'Ti.API.log.timestamp');
Ti.API.log('timestamp', ['Ti.API.timestamp.0', 'Ti.API.timestamp.1']);
}
Sample Test App with Buttons:
var win = Ti.UI.createWindow({
backgroundColor : 'blue',
layout : 'vertical'
});
var con = Ti.UI.createButton({title:'console', height : '20%', width : '80%'});
var api = Ti.UI.createButton({title:'api', height : '20%', width : '80%'});
var log = Ti.UI.createButton({title:'log', height : '20%', width : '80%'});
var all = Ti.UI.createButton({title:'all', height : '20%', width : '80%'});
var array = Ti.UI.createButton({title:'array', height : '20%', width : '80%'});
con.addEventListener('click', function(){
console.trace('console.trace');
console.debug('console.debug');
console.info('console.info');
console.warn('console.warn');
console.error('console.error');
});
api.addEventListener('click', function(){
Ti.API.trace('Ti.API.trace');
Ti.API.debug('Ti.API.debug');
Ti.API.info('Ti.API.info');
Ti.API.warn('Ti.API.warn');
Ti.API.error('Ti.API.error');
});
log.addEventListener('click', function(){
Ti.API.log('trace', 'Ti.API.log(trace)');
Ti.API.log('debug', 'Ti.API.log(debug)');
Ti.API.log('info', 'Ti.API.log(info)');
Ti.API.log('warn', 'Ti.API.log(warn)');
Ti.API.log('error', 'Ti.API.log(error)');
Ti.API.log('custom', 'Ti.API.log(custom)');
Ti.API.log('custom', ['Ti.API.log(custom, [])', 'arg1', 'arg2']);
});
all.addEventListener('click', function(){
con.fireEvent('click');
api.fireEvent('click');
log.fireEvent('click');
switch(Ti.Platform.osname)
{
case 'iphone':
case 'ipad': Ti.API.timestamp();
}
});
array.addEventListener('click', function(){
var a = ['long string', 0, 'pig', 'goat', 'BIGCAPS', 999, '000', 'TWO GO'];
console.info(a);
Ti.API.info(a);
Ti.API.log('custom', a);
switch(Ti.Platform.osname)
{
case 'iphone':
case 'ipad': Ti.API.timestamp(a);
}
});
win.add(con);
win.add(api);
win.add(log);
win.add(all);
win.add(array);
win.open();
Not sure we should deprecate them now that they are properly documented. I'm adding them to mobile web for parity's sake. If they get ripped out, then they get ripped out.
Before we make any changes to the API, a larger discussion is required to determine exactly what it should look like. If the API is changing, it should change once. Cross platform logging semantics should be defined in a requirements discussion before any development occurs. Updating this ticket to represent the need for a larger cross platform logging definition.
Remember to consider TIMOB-11551 (iOS: API.log with timestamp arg fails to log timestamp) during the resolution of this issue.
Pretty sure this was cleaned up years ago, as the mentioned methods don't exist