debuggingmobilecross-platformtemenos-quantum

How to get a Kony application's name at runtime


I'm writing a logger module for a Kony app to print out debugging statements. The Kony SDK already has a kony.print function but I'd like this logger to print out the application's name as a prefix to each statement, to get something like:

FooApp: x is 1
FooApp: a is ["hello", "world"]

The point here is to make it easier for me to filter/find my debug statements in the Xcode or Android Studio logs while debugging.

So I'm aiming to write something like:

var Logger = (function(){

    var prefix = ""; //kony.getAppId()?

    return{
        print: function(message){
            kony.print(`${prefix}: ${message}`);
        }
    };
})();

So the question is whether there is anything like a kony.getAppId() function, a constant or equivalent I can query to get the appropriate value for prefix in order to make the module reusable, rather than hard-code it for every project.


Solution

  • I've found that there's an appConfig variable built into every Kony app that includes useful information about the application like its name and version. So now I can initialise the prefix variable in my module like this:

    var prefix = appConfig.appId || appConfig.appName;
    

    I hope this is useful to others.