简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM