Logging messages while entering and leaving a definition in python using a decorator for all definitions -
i not able print print("leaving definition : " + func._name_)
in following code snippet
from functools import wraps def notification(func): @wraps(func) def with_logging(*args, **kwargs): print("entering definition : " + func.__name__) print("arguments passed : {0} {1}".format(args,kwargs)) d = func(*args, **kwargs) print("leaving definition : " + func._name_) return d return d return with_logging @notification def addition_func(x): """""" return x result = addition_func(4) print(result)
Comments
Post a Comment