Представляю себе код примерно так:
import types
class ClassWithLoggedFunctions(type):
def __call__(self, *args, **kargs):
self.instance = super(ClassWithLoggedFunctions, self).__call__(*args,**kargs)
def __call__(self, *args, **kargs):
print 'execution %s(%s, %s)' % (func, args, kargs)
func.__call__(self, *args, **kargs)
for i in dir(self.instance):
func = getattr(self.instance, i)
if isinstance(func, types.MethodType):
pass # magic here!
return self.instance
class C():
__metaclass__ = ClassWithLoggedFunctions
def f(self, a, b, c):
return (a,b,c)
C().f(1,2,3)
Есть идеи?