from functools import wraps
import logging
logger = logging.getLogger(__name__)


def tracking(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        parts = []
        arg_str = ", ".join(map(str, args))
        if arg_str:
            parts.append(arg_str)
        arg_str = ", ".join([f'{k}={v}' for k, v in kwargs.items()])
        if arg_str:
            parts.append(arg_str)
        arg_str = ', '.join(parts)
        logger.warning(f'STARTING func: {func.__name__}({arg_str}), code: {func.__code__}')
        res = func(*args, **kwargs)
        logger.warning(f'ENDING func: {func.__name__}, return: {res}')
        return res
    return wrapper


if __name__ == '__main__':
    @tracking
    def test(*args, **kwargs):
        pass

    test(*['1', 2], **{'1': 1, '2': '2'})
