from casatasks import casalog
def log_origin_setter(func):
This is a decorator function for a task calls other tasks.
if it get the parameter '__log_origin', read it and set origin to the casalog.
otherwise it reads the function name and set origin to the logger.
So you don't need to set origin in the task any more.
kwargs['__log_origin'] = 'othertask'
sometask(*args, **kwargs) # logged "othertask::..."
def wrapper(*args, **kwargs):
caller = kwargs.pop('__log_origin', func.__name__)
retval = func(*args, **kwargs)
if caller != func.__name__:
kwargs['__log_origin'] = caller