Is there anyway from within scripts that I can elegantly log the script/function?
Ideally, I'd like to abstract out a logging function that can reflect back to the callstack.
So - say a script "SHAREDFUNCTIONS" had a method "saveTable" in -
Code: Select all
importPackage(org.apache.log4j);
var logger = Logger.getLogger("MyLog");
.....
function saveTable(param)
{
myLog("Saving stuff");
}
function myLog(message)
{
//some magic here to reflect the call stack
//function = this.callstack.pop
//script = this.name;
logger.info(function + script + message);
}
Code: Select all
[Date time] INFO SHAREDFUNCTIONS saveTable Saving Stuff
I've looked at the various parameters for log4j, but note it's the depreciated 1.2 release, and I can't seem to get this information out?
Cheers,
Peter