def action_logging(f):
@functools.wraps(f)<EOL>def wrapper(*args, **kwargs):<EOL><INDENT>"""<STR_LIT>"""<EOL>assert args<EOL>assert isinstance(args[<NUM_LIT:0>], Namespace),"<STR_LIT>""<STR_LIT>".format(args[<NUM_LIT:0>])<EOL>metrics = _build_metrics(f.__name__, args[<NUM_LIT:0>])<EOL>cli_action_loggers.on_pre_execution(**metrics)<EOL>try:<EOL><INDENT>return f(*args, **kwargs)<EOL><DEDENT>except Exception as e:<EOL><INDENT>metrics['<STR_LIT:error>'] = e<EOL>raise<EOL><DEDENT>finally:<EOL><INDENT>metrics['<STR_LIT>'] = datetime.utcnow()<EOL>cli_action_loggers.on_post_execution(**metrics)<EOL><DEDENT><DEDENT>return wrapper<EOL>
Decorates function to execute function at the same time submitting action_logging
but in CLI context. It will call action logger callbacks twice,
one for pre-execution and the other one for post-execution.

Action logger will be called with below keyword parameters:
    sub_command : name of sub-command
    start_datetime : start datetime instance by utc
    end_datetime : end datetime instance by utc
    full_command : full command line arguments
    user : current user
    log : airflow.models.log.Log ORM instance
    dag_id : dag id (optional)
    task_id : task_id (optional)
    execution_date : execution date (optional)
    error : exception instance if there's an exception

:param f: function instance
:return: wrapped function