human
Complete this python program:
def dotrace(*args, **kwds):
assistant
#Here is the Python program you requested.

    """Function decorator to trace a function\s entry and exit.
    *args: categories in which to trace this function. Example usage:
    @trace
    def function(...):...
    @trace(\mycategory\)
    def function(...):...
    """
    recursive = kwds.get('recursive', False)
    def decorator(func):
        spec = None
        logger = logging.getLogger('trace')
        def wrapper(*args, **kwds):
            if ((not logger.isEnabledFor(logging.INFO)) or tls.tracing):
                return func(*args, **kwds)
            (fname, ftype) = find_function_info(func, spec, args)
            try:
                tls.tracing = True
                (enter, leave) = create_events(fname, spec, args, kwds)
                try:
                    logger.info(''.join(enter))
                    tls.indent += 1
                    try:
                        try:
                            tls.tracing = False
                            result = func(*args, **kwds)
                        finally:
                            tls.tracing = True
                    except:
                        (type, value, traceback) = sys.exc_info()
                        leave.append('    =>    exception    thrown\n DCTB raise    ')
                        mname = type.__module__
                        if (mname != '__main__'):
                            leave.append(mname)
                            leave.append('.')
                        leave.append(type.__name__)
                        if value.args:
                            leave.append('(')
                            leave.append(',    '.join((chop(v) for v in value.args)))
                            leave.append(')')
                        else:
                            leave.append('()')
                        raise
                    else:
                        if (result is not None):
                            leave.append('    ->    ')
                            leave.append(chop(result))
                finally:
                    tls.indent -= 1
                    logger.info(''.join(leave))
            finally:
                tls.tracing = False
            return result
        result = None
        rewrap = (lambda x: x)
        if (type(func) == classmethod):
     ...