Add this little class to your file where you load your models:
# AOP stands for Aspect Oriented Programming, basicly, it's combining aspects
# For other scripters who want to use this, feel free to.
# But beware, the new function must take as it's first parameter the old function
# -MLeo
class AOP:
def __init__(self, oldFunc, newFunc):
self.oldFunc = oldFunc
self.newFunc = newFunc
def __call__(self, *args):
return apply(self.newFunc, (self.oldFunc,) + args)
And then add this:
def FuncPrinter(old, strTheModel, *args):
debug("Entering: " + getattr(old, "__name__", str(old)))
debug("Loading: '" + strTheModel + "'")
apply(old, (strTheModel,) + args)
debug("Exiting")
And then wrap your model loading function with the AOP class like this:
def oldFunc(....): ....
oldFunc = AOP(oldFunc, FuncPrinter)
The reason I use debug there, is because it's small, and perhaps even more importantly, it's crashproof because it always opens, writes to, and closes the output file.
Also, do note that this assumes that the first argument of the model loading function is the string defining the model path.
If it's a class that's doing the loading then do the following:
def MethWriter(old, other, strTheModel, *args):
debug("Entering: " + getattr(old, "__name__", str(old)))
debug("Loading: '" + strTheModel + "'")
apply(old, (other, strTheModel,) + args)
debug("Exiting")
ModelLoaderClass.loadingMethod = AOP(MethWriter, ModelLoaderClass.loadingMethod)