One little oversight in the API for each translator is there isn’t a built in function to say what kind of translator instance one is in. Jeff Drum asked about this problem this morning so I altered some code from the translator and came up with this little module which adds in an iguana.project.type() library function which returns a short string indicating the type of translator instance one is in.
It’s written efficiently in that in caches the translator type so you can just use it.
I dropped the module into the Iguana GIT repo this morning:
One handy use of this function is to improve the logging for a channel with multiple translator instances to tell which translator instance is logging:
privateLogInfo = iguana.logInfo
if B then
privateLogInfo(iguana.project.type() .. " translator: " .. A, B)
privateLogInfo(iguana.project.type() .. " translator: " .. A)
The code above shows how one can replace the built in iguana.logInfo command with one which prefixes the type of the translator instance which is logging.
I implemented this on a few interfaces yesterday and today, creating wrappers for iguana.logInfo/Warning/Error/Debug in the process. Very useful for debugging when you’re running multiple translators in a single channel!
Jeff Drumm ◊ VP and COO ◊ HICG, LLC. ◊ http://www.hicgrp.com
You must be logged in to reply to this topic.